clickgo 3.16.27 → 4.0.0
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/README.md +20 -9
- package/dist/app/{demo/res/video.mp4 → demo.cga} +0 -0
- package/dist/app/task.cga +0 -0
- package/dist/control/arteditor.cgc +0 -0
- package/dist/control/box.cgc +0 -0
- package/dist/control/captcha.cgc +0 -0
- package/dist/control/common.cgc +0 -0
- package/dist/control/desc.cgc +0 -0
- package/dist/control/drawer.cgc +0 -0
- package/dist/control/echarts.cgc +0 -0
- package/dist/control/form.cgc +0 -0
- package/dist/control/iconview.cgc +0 -0
- package/dist/control/jodit.cgc +0 -0
- package/dist/control/map.cgc +0 -0
- package/dist/control/monaco.cgc +0 -0
- package/dist/control/mpegts.cgc +0 -0
- package/dist/control/nav.cgc +0 -0
- package/dist/control/novnc.cgc +0 -0
- package/dist/control/page.cgc +0 -0
- package/dist/control/pdf.cgc +0 -0
- package/dist/control/property.cgc +0 -0
- package/dist/control/qrcode.cgc +0 -0
- package/dist/control/table.cgc +0 -0
- package/dist/control/task.cgc +0 -0
- package/dist/control/tplink.cgc +0 -0
- package/dist/control/tuieditor.cgc +0 -0
- package/dist/control/tuiviewer.cgc +0 -0
- package/dist/control/tums.cgc +0 -0
- package/dist/control/xterm.cgc +0 -0
- package/dist/ext/tums-player/audio.wasm +0 -0
- package/dist/ext/tums-player/decoder.worker.js +129 -0
- package/dist/ext/tums-player/libaudio.js +1 -0
- package/dist/ext/tums-player/libaudio.wasm +0 -0
- package/dist/ext/tums-player/libffmpeg.js +1 -0
- package/dist/ext/tums-player/libffmpeg.wasm +0 -0
- package/dist/ext/tums-player/libs.worker.js +92 -0
- package/dist/ext/tums-player/tums-player.umd.min.js +35 -0
- package/dist/ext/tums-player/webgl.js +2 -0
- package/dist/ext/tums-player/webgl.worker.js +42 -0
- package/dist/global.css +1 -1
- package/dist/index.js +1 -187
- package/dist/theme/dark.cgt +0 -0
- package/dist/theme/light.cgt +0 -0
- package/package.json +16 -10
- package/dist/app/demo/app.js +0 -60
- package/dist/app/demo/config.json +0 -249
- package/dist/app/demo/form/control/alayout2/alayout2.js +0 -43
- package/dist/app/demo/form/control/alayout2/alayout2.xml +0 -16
- package/dist/app/demo/form/control/alert/alert.js +0 -43
- package/dist/app/demo/form/control/alert/alert.xml +0 -32
- package/dist/app/demo/form/control/arteditor/arteditor.js +0 -75
- package/dist/app/demo/form/control/arteditor/arteditor.xml +0 -12
- package/dist/app/demo/form/control/arteditor/img.js +0 -61
- package/dist/app/demo/form/control/arteditor/img.xml +0 -6
- package/dist/app/demo/form/control/block/block.css +0 -1
- package/dist/app/demo/form/control/block/block.scss +0 -17
- package/dist/app/demo/form/control/block/block.xml +0 -7
- package/dist/app/demo/form/control/box/box.js +0 -87
- package/dist/app/demo/form/control/box/box.xml +0 -23
- package/dist/app/demo/form/control/button/button.css +0 -1
- package/dist/app/demo/form/control/button/button.js +0 -62
- package/dist/app/demo/form/control/button/button.scss +0 -18
- package/dist/app/demo/form/control/button/button.xml +0 -133
- package/dist/app/demo/form/control/calendar/calendar.js +0 -62
- package/dist/app/demo/form/control/calendar/calendar.xml +0 -34
- package/dist/app/demo/form/control/captcha/captcha.js +0 -60
- package/dist/app/demo/form/control/captcha/captcha.xml +0 -10
- package/dist/app/demo/form/control/check/check.js +0 -65
- package/dist/app/demo/form/control/check/check.xml +0 -17
- package/dist/app/demo/form/control/circle/circle.xml +0 -36
- package/dist/app/demo/form/control/content/content.js +0 -58
- package/dist/app/demo/form/control/content/content.xml +0 -16
- package/dist/app/demo/form/control/date/date.js +0 -56
- package/dist/app/demo/form/control/date/date.xml +0 -28
- package/dist/app/demo/form/control/datepanel/datepanel.js +0 -63
- package/dist/app/demo/form/control/datepanel/datepanel.xml +0 -32
- package/dist/app/demo/form/control/daterange/daterange.js +0 -54
- package/dist/app/demo/form/control/daterange/daterange.xml +0 -22
- package/dist/app/demo/form/control/delete/delete.js +0 -58
- package/dist/app/demo/form/control/delete/delete.xml +0 -20
- package/dist/app/demo/form/control/desc/desc.js +0 -82
- package/dist/app/demo/form/control/desc/desc.xml +0 -44
- package/dist/app/demo/form/control/dialog/dialog.js +0 -47
- package/dist/app/demo/form/control/dialog/dialog.xml +0 -32
- package/dist/app/demo/form/control/drawer/drawer.js +0 -45
- package/dist/app/demo/form/control/drawer/drawer.xml +0 -34
- package/dist/app/demo/form/control/echarts/echarts.js +0 -137
- package/dist/app/demo/form/control/echarts/echarts.xml +0 -12
- package/dist/app/demo/form/control/empty/empty.js +0 -44
- package/dist/app/demo/form/control/empty/empty.xml +0 -9
- package/dist/app/demo/form/control/file/file.js +0 -60
- package/dist/app/demo/form/control/file/file.xml +0 -25
- package/dist/app/demo/form/control/flow/flow.css +0 -1
- package/dist/app/demo/form/control/flow/flow.js +0 -97
- package/dist/app/demo/form/control/flow/flow.scss +0 -18
- package/dist/app/demo/form/control/flow/flow.xml +0 -101
- package/dist/app/demo/form/control/form/form.css +0 -1
- package/dist/app/demo/form/control/form/form.js +0 -77
- package/dist/app/demo/form/control/form/form.scss +0 -5
- package/dist/app/demo/form/control/form/form.xml +0 -29
- package/dist/app/demo/form/control/grid/grid.js +0 -45
- package/dist/app/demo/form/control/grid/grid.xml +0 -27
- package/dist/app/demo/form/control/group/group.js +0 -50
- package/dist/app/demo/form/control/group/group.xml +0 -46
- package/dist/app/demo/form/control/hske/hske.js +0 -44
- package/dist/app/demo/form/control/hske/hske.xml +0 -19
- package/dist/app/demo/form/control/html/html.js +0 -70
- package/dist/app/demo/form/control/html/html.xml +0 -18
- package/dist/app/demo/form/control/icon/icon.xml +0 -49
- package/dist/app/demo/form/control/iconview/iconview.js +0 -191
- package/dist/app/demo/form/control/iconview/iconview.xml +0 -45
- package/dist/app/demo/form/control/img/img.xml +0 -26
- package/dist/app/demo/form/control/imgviewer/imgviewer.js +0 -46
- package/dist/app/demo/form/control/imgviewer/imgviewer.xml +0 -9
- package/dist/app/demo/form/control/jodit/jodit.js +0 -75
- package/dist/app/demo/form/control/jodit/jodit.xml +0 -24
- package/dist/app/demo/form/control/label/label.js +0 -51
- package/dist/app/demo/form/control/label/label.xml +0 -34
- package/dist/app/demo/form/control/layout/layout.js +0 -45
- package/dist/app/demo/form/control/layout/layout.xml +0 -18
- package/dist/app/demo/form/control/link/link.js +0 -53
- package/dist/app/demo/form/control/link/link.xml +0 -30
- package/dist/app/demo/form/control/list/list.css +0 -1
- package/dist/app/demo/form/control/list/list.js +0 -394
- package/dist/app/demo/form/control/list/list.scss +0 -7
- package/dist/app/demo/form/control/list/list.xml +0 -150
- package/dist/app/demo/form/control/loading/loading.xml +0 -8
- package/dist/app/demo/form/control/map/map.js +0 -217
- package/dist/app/demo/form/control/map/map.xml +0 -44
- package/dist/app/demo/form/control/marquee/marquee.js +0 -64
- package/dist/app/demo/form/control/marquee/marquee.xml +0 -33
- package/dist/app/demo/form/control/menu/menu.js +0 -67
- package/dist/app/demo/form/control/menu/menu.xml +0 -125
- package/dist/app/demo/form/control/monaco/monaco.js +0 -136
- package/dist/app/demo/form/control/monaco/monaco.xml +0 -28
- package/dist/app/demo/form/control/mpegts/mpegts.js +0 -70
- package/dist/app/demo/form/control/mpegts/mpegts.xml +0 -11
- package/dist/app/demo/form/control/nav/nav.js +0 -71
- package/dist/app/demo/form/control/nav/nav.xml +0 -106
- package/dist/app/demo/form/control/page/page.js +0 -51
- package/dist/app/demo/form/control/page/page.xml +0 -22
- package/dist/app/demo/form/control/palette/palette.js +0 -46
- package/dist/app/demo/form/control/palette/palette.xml +0 -16
- package/dist/app/demo/form/control/panel/panel.js +0 -117
- package/dist/app/demo/form/control/panel/panel.xml +0 -16
- package/dist/app/demo/form/control/panel/test1.js +0 -105
- package/dist/app/demo/form/control/panel/test1.xml +0 -22
- package/dist/app/demo/form/control/panel/test2.xml +0 -4
- package/dist/app/demo/form/control/pdf/pdf.js +0 -78
- package/dist/app/demo/form/control/pdf/pdf.xml +0 -12
- package/dist/app/demo/form/control/pdf/test.pdf +0 -0
- package/dist/app/demo/form/control/progress/progress.js +0 -63
- package/dist/app/demo/form/control/progress/progress.xml +0 -9
- package/dist/app/demo/form/control/property/property.js +0 -166
- package/dist/app/demo/form/control/property/property.xml +0 -6
- package/dist/app/demo/form/control/qrcode/qrcode.js +0 -45
- package/dist/app/demo/form/control/qrcode/qrcode.xml +0 -13
- package/dist/app/demo/form/control/radio/radio.js +0 -62
- package/dist/app/demo/form/control/radio/radio.xml +0 -15
- package/dist/app/demo/form/control/scroll/scroll.js +0 -52
- package/dist/app/demo/form/control/scroll/scroll.xml +0 -38
- package/dist/app/demo/form/control/select/select.js +0 -286
- package/dist/app/demo/form/control/select/select.xml +0 -141
- package/dist/app/demo/form/control/setting/setting.xml +0 -11
- package/dist/app/demo/form/control/sgroup/sgroup.xml +0 -28
- package/dist/app/demo/form/control/step/step.js +0 -61
- package/dist/app/demo/form/control/step/step.xml +0 -16
- package/dist/app/demo/form/control/svg/svg.js +0 -61
- package/dist/app/demo/form/control/svg/svg.xml +0 -24
- package/dist/app/demo/form/control/switch/switch.js +0 -64
- package/dist/app/demo/form/control/switch/switch.xml +0 -29
- package/dist/app/demo/form/control/tab/tab.js +0 -113
- package/dist/app/demo/form/control/tab/tab.xml +0 -22
- package/dist/app/demo/form/control/table/table.js +0 -233
- package/dist/app/demo/form/control/table/table.xml +0 -97
- package/dist/app/demo/form/control/tag/tag.js +0 -44
- package/dist/app/demo/form/control/tag/tag.xml +0 -52
- package/dist/app/demo/form/control/text/text.js +0 -127
- package/dist/app/demo/form/control/text/text.xml +0 -70
- package/dist/app/demo/form/control/timeline/timeline.js +0 -43
- package/dist/app/demo/form/control/timeline/timeline.xml +0 -19
- package/dist/app/demo/form/control/tip/tip.js +0 -43
- package/dist/app/demo/form/control/tip/tip.xml +0 -42
- package/dist/app/demo/form/control/tplink/tplink.js +0 -74
- package/dist/app/demo/form/control/tplink/tplink.xml +0 -13
- package/dist/app/demo/form/control/tuieditor/tuieditor.js +0 -73
- package/dist/app/demo/form/control/tuieditor/tuieditor.xml +0 -22
- package/dist/app/demo/form/control/tuiviewer/tuiviewer.js +0 -45
- package/dist/app/demo/form/control/tuiviewer/tuiviewer.xml +0 -14
- package/dist/app/demo/form/control/uploader/uploader.js +0 -91
- package/dist/app/demo/form/control/uploader/uploader.xml +0 -15
- package/dist/app/demo/form/control/vflow/vflow.css +0 -1
- package/dist/app/demo/form/control/vflow/vflow.js +0 -112
- package/dist/app/demo/form/control/vflow/vflow.scss +0 -22
- package/dist/app/demo/form/control/vflow/vflow.xml +0 -89
- package/dist/app/demo/form/control/video/video.js +0 -47
- package/dist/app/demo/form/control/video/video.xml +0 -14
- package/dist/app/demo/form/control/web/web.js +0 -43
- package/dist/app/demo/form/control/web/web.xml +0 -4
- package/dist/app/demo/form/control/xterm/xterm.js +0 -100
- package/dist/app/demo/form/control/xterm/xterm.xml +0 -6
- package/dist/app/demo/form/event/form/form.css +0 -1
- package/dist/app/demo/form/event/form/form.js +0 -180
- package/dist/app/demo/form/event/form/form.scss +0 -24
- package/dist/app/demo/form/event/form/form.xml +0 -16
- package/dist/app/demo/form/event/other/other.js +0 -78
- package/dist/app/demo/form/event/other/other.xml +0 -5
- package/dist/app/demo/form/event/screen/screen.js +0 -86
- package/dist/app/demo/form/event/screen/screen.xml +0 -9
- package/dist/app/demo/form/event/task/task.js +0 -111
- package/dist/app/demo/form/event/task/task.xml +0 -20
- package/dist/app/demo/form/main.css +0 -1
- package/dist/app/demo/form/main.js +0 -521
- package/dist/app/demo/form/main.scss +0 -9
- package/dist/app/demo/form/main.xml +0 -160
- package/dist/app/demo/form/method/acontrol/acontrol.js +0 -53
- package/dist/app/demo/form/method/acontrol/acontrol.xml +0 -5
- package/dist/app/demo/form/method/aform/aform.js +0 -123
- package/dist/app/demo/form/method/aform/aform.xml +0 -60
- package/dist/app/demo/form/method/aform/sd.js +0 -58
- package/dist/app/demo/form/method/aform/sd.xml +0 -7
- package/dist/app/demo/form/method/core/core.js +0 -111
- package/dist/app/demo/form/method/core/core.xml +0 -23
- package/dist/app/demo/form/method/dom/dom.css +0 -1
- package/dist/app/demo/form/method/dom/dom.js +0 -251
- package/dist/app/demo/form/method/dom/dom.scss +0 -10
- package/dist/app/demo/form/method/dom/dom.xml +0 -76
- package/dist/app/demo/form/method/form/form.js +0 -287
- package/dist/app/demo/form/method/form/form.xml +0 -74
- package/dist/app/demo/form/method/form/test.xml +0 -5
- package/dist/app/demo/form/method/fs/fs.js +0 -230
- package/dist/app/demo/form/method/fs/fs.xml +0 -18
- package/dist/app/demo/form/method/fs/text.js +0 -48
- package/dist/app/demo/form/method/fs/text.xml +0 -3
- package/dist/app/demo/form/method/native/native.js +0 -128
- package/dist/app/demo/form/method/native/native.xml +0 -22
- package/dist/app/demo/form/method/storage/storage.js +0 -95
- package/dist/app/demo/form/method/storage/storage.xml +0 -18
- package/dist/app/demo/form/method/system/system.js +0 -88
- package/dist/app/demo/form/method/system/system.xml +0 -14
- package/dist/app/demo/form/method/task/locale1.json +0 -3
- package/dist/app/demo/form/method/task/locale2.json +0 -3
- package/dist/app/demo/form/method/task/task.js +0 -196
- package/dist/app/demo/form/method/task/task.xml +0 -61
- package/dist/app/demo/form/method/theme/theme.js +0 -107
- package/dist/app/demo/form/method/theme/theme.xml +0 -12
- package/dist/app/demo/form/method/tool/tool.js +0 -143
- package/dist/app/demo/form/method/tool/tool.xml +0 -40
- package/dist/app/demo/form/method/zip/zip.js +0 -137
- package/dist/app/demo/form/method/zip/zip.xml +0 -12
- package/dist/app/demo/form/solution/backpanel/backpanel.js +0 -89
- package/dist/app/demo/form/solution/backpanel/backpanel.xml +0 -31
- package/dist/app/demo/global.css +0 -3
- package/dist/app/demo/res/custombtn.cgc +0 -0
- package/dist/app/demo/res/icon.svg +0 -5
- package/dist/app/demo/res/img.jpg +0 -0
- package/dist/app/demo/res/marker.svg +0 -5
- package/dist/app/demo/res/r-1.svg +0 -32
- package/dist/app/demo/res/r-2.svg +0 -38
- package/dist/app/demo/res/sql.svg +0 -25
- package/dist/app/demo/res/txt.svg +0 -21
- package/dist/app/demo/res/zip.svg +0 -21
- package/dist/app/task/app.js +0 -57
- package/dist/app/task/config.json +0 -29
- package/dist/app/task/form/bar/bar.js +0 -419
- package/dist/app/task/form/bar/bar.xml +0 -46
- package/dist/app/task/form/desktop/desktop.xml +0 -1
- package/dist/app/task/locale/en.json +0 -11
- package/dist/app/task/locale/ja.json +0 -11
- package/dist/app/task/locale/sc.json +0 -11
- package/dist/app/task/locale/tc.json +0 -11
- package/dist/clickgo.d.ts +0 -22
- package/dist/clickgo.js +0 -109
- package/dist/index.d.ts +0 -55
- package/dist/lib/control.d.ts +0 -53
- package/dist/lib/control.js +0 -606
- package/dist/lib/core.d.ts +0 -47
- package/dist/lib/core.js +0 -1028
- package/dist/lib/dom.d.ts +0 -75
- package/dist/lib/dom.js +0 -2176
- package/dist/lib/form.d.ts +0 -222
- package/dist/lib/form.js +0 -3033
- package/dist/lib/fs.d.ts +0 -35
- package/dist/lib/fs.js +0 -1241
- package/dist/lib/native.d.ts +0 -43
- package/dist/lib/native.js +0 -228
- package/dist/lib/storage.d.ts +0 -6
- package/dist/lib/storage.js +0 -227
- package/dist/lib/task.d.ts +0 -32
- package/dist/lib/task.js +0 -1875
- package/dist/lib/theme.d.ts +0 -8
- package/dist/lib/theme.js +0 -195
- package/dist/lib/tool.d.ts +0 -122
- package/dist/lib/tool.js +0 -1054
- package/dist/lib/zip.d.ts +0 -40
- package/dist/lib/zip.js +0 -397
- package/dist/theme/blue.cgt +0 -0
- package/dist/theme/byterun.cgt +0 -0
- package/types/index.d.ts +0 -1374
package/dist/lib/dom.js
DELETED
|
@@ -1,2176 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.is = exports.dpi = void 0;
|
|
46
|
-
exports.inPage = inPage;
|
|
47
|
-
exports.setGlobalCursor = setGlobalCursor;
|
|
48
|
-
exports.hasTouchButMouse = hasTouchButMouse;
|
|
49
|
-
exports.createToStyleList = createToStyleList;
|
|
50
|
-
exports.removeFromStyleList = removeFromStyleList;
|
|
51
|
-
exports.pushStyle = pushStyle;
|
|
52
|
-
exports.removeStyle = removeStyle;
|
|
53
|
-
exports.getStyleCount = getStyleCount;
|
|
54
|
-
exports.watchPosition = watchPosition;
|
|
55
|
-
exports.unwatchPosition = unwatchPosition;
|
|
56
|
-
exports.isWatchPosition = isWatchPosition;
|
|
57
|
-
exports.clearWatchPosition = clearWatchPosition;
|
|
58
|
-
exports.getWatchSizeCount = getWatchSizeCount;
|
|
59
|
-
exports.watchSize = watchSize;
|
|
60
|
-
exports.unwatchSize = unwatchSize;
|
|
61
|
-
exports.isWatchSize = isWatchSize;
|
|
62
|
-
exports.clearWatchSize = clearWatchSize;
|
|
63
|
-
exports.getWatchCount = getWatchCount;
|
|
64
|
-
exports.watch = watch;
|
|
65
|
-
exports.unwatch = unwatch;
|
|
66
|
-
exports.isWatch = isWatch;
|
|
67
|
-
exports.clearWatch = clearWatch;
|
|
68
|
-
exports.watchStyle = watchStyle;
|
|
69
|
-
exports.isWatchStyle = isWatchStyle;
|
|
70
|
-
exports.clearWatchStyle = clearWatchStyle;
|
|
71
|
-
exports.watchProperty = watchProperty;
|
|
72
|
-
exports.isWatchProperty = isWatchProperty;
|
|
73
|
-
exports.clearWatchProperty = clearWatchProperty;
|
|
74
|
-
exports.getWatchInfo = getWatchInfo;
|
|
75
|
-
exports.bindClick = bindClick;
|
|
76
|
-
exports.bindDblClick = bindDblClick;
|
|
77
|
-
exports.bindDown = bindDown;
|
|
78
|
-
exports.bindScale = bindScale;
|
|
79
|
-
exports.bindGesture = bindGesture;
|
|
80
|
-
exports.allowEvent = allowEvent;
|
|
81
|
-
exports.bindLong = bindLong;
|
|
82
|
-
exports.setDragData = setDragData;
|
|
83
|
-
exports.bindDrag = bindDrag;
|
|
84
|
-
exports.bindMove = bindMove;
|
|
85
|
-
exports.bindResize = bindResize;
|
|
86
|
-
exports.findParentByData = findParentByData;
|
|
87
|
-
exports.findParentByClass = findParentByClass;
|
|
88
|
-
exports.findParentByTag = findParentByTag;
|
|
89
|
-
exports.index = index;
|
|
90
|
-
exports.siblings = siblings;
|
|
91
|
-
exports.siblingsData = siblingsData;
|
|
92
|
-
exports.fullscreen = fullscreen;
|
|
93
|
-
exports.exitFullscreen = exitFullscreen;
|
|
94
|
-
exports.createElement = createElement;
|
|
95
|
-
const clickgo = __importStar(require("../clickgo"));
|
|
96
|
-
const form = __importStar(require("./form"));
|
|
97
|
-
const core = __importStar(require("./core"));
|
|
98
|
-
const tool = __importStar(require("./tool"));
|
|
99
|
-
const topClass = ['#cg-form-list', '#cg-pop-list', '#cg-notify', '#cg-alert', '#cg-simpletask', '#cg-launcher', '#cg-confirm'];
|
|
100
|
-
function classUnfold(after, out = []) {
|
|
101
|
-
const arr = [];
|
|
102
|
-
for (const name of topClass) {
|
|
103
|
-
if (out.includes(name)) {
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
arr.push(name + (after ? (' ' + after) : ''));
|
|
107
|
-
}
|
|
108
|
-
return arr.join(', ');
|
|
109
|
-
}
|
|
110
|
-
const styleList = document.createElement('div');
|
|
111
|
-
styleList.style.display = 'none';
|
|
112
|
-
document.getElementsByTagName('body')[0].appendChild(styleList);
|
|
113
|
-
styleList.insertAdjacentHTML('beforeend', '<style id=\'cg-global-cursor\'></style>');
|
|
114
|
-
styleList.insertAdjacentHTML('beforeend', `<style id='cg-global'>
|
|
115
|
-
${classUnfold()} {-webkit-user-select: none; user-select: none; cursor: default; box-sizing: border-box;}
|
|
116
|
-
${topClass.slice(0, 4).join(', ')} {left: 0; top: 0; width: 0; height: 0; position: absolute;}
|
|
117
|
-
${classUnfold('img')} {vertical-align: bottom;}
|
|
118
|
-
${classUnfold('::selection', ['#cg-launcher'])} {background-color: rgba(0, 0, 0, .1);}
|
|
119
|
-
${classUnfold('*')}, ${classUnfold('*::after')}, ${classUnfold('*::before')} {box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); flex-shrink: 0;}
|
|
120
|
-
${classUnfold(' > div')} {font-family: var(--g-family); font-size: var(--g-size); line-height: 1; -webkit-font-smoothing: antialiased;}
|
|
121
|
-
</style>`);
|
|
122
|
-
function inPage(el) {
|
|
123
|
-
return document.body.contains(el);
|
|
124
|
-
}
|
|
125
|
-
const dpiDiv = document.createElement('div');
|
|
126
|
-
dpiDiv.style.visibility = 'hidden';
|
|
127
|
-
dpiDiv.style.width = '1in';
|
|
128
|
-
document.getElementsByTagName('body')[0].appendChild(dpiDiv);
|
|
129
|
-
exports.dpi = dpiDiv.getBoundingClientRect().width;
|
|
130
|
-
dpiDiv.remove();
|
|
131
|
-
let globalCursorStyle;
|
|
132
|
-
function setGlobalCursor(type) {
|
|
133
|
-
if (!globalCursorStyle) {
|
|
134
|
-
globalCursorStyle = document.getElementById('cg-global-cursor');
|
|
135
|
-
}
|
|
136
|
-
if (type) {
|
|
137
|
-
globalCursorStyle.innerHTML = `* {cursor: ${type} !important;}`;
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
globalCursorStyle.innerHTML = '';
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
let lastTouchTime = 0;
|
|
144
|
-
document.addEventListener('touchstart', function () {
|
|
145
|
-
lastTouchTime = Date.now();
|
|
146
|
-
}, {
|
|
147
|
-
'passive': true
|
|
148
|
-
});
|
|
149
|
-
function hasTouchButMouse(e) {
|
|
150
|
-
if (e instanceof TouchEvent || e.type === 'touchstart') {
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
if ((e.pointerType === 'touch') && (e.type === 'contextmenu')) {
|
|
154
|
-
return true;
|
|
155
|
-
}
|
|
156
|
-
const now = Date.now();
|
|
157
|
-
if (now - lastTouchTime < 60000) {
|
|
158
|
-
return true;
|
|
159
|
-
}
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
function createToStyleList(taskId) {
|
|
163
|
-
styleList.insertAdjacentHTML('beforeend', `<div id="cg-style-task${taskId}"><div class="cg-style-control"></div><div class="cg-style-theme"></div><style class="cg-style-global"></style><div class="cg-style-form"></div></div>`);
|
|
164
|
-
}
|
|
165
|
-
function removeFromStyleList(taskId) {
|
|
166
|
-
var _a;
|
|
167
|
-
(_a = document.getElementById('cg-style-task' + taskId.toString())) === null || _a === void 0 ? void 0 : _a.remove();
|
|
168
|
-
}
|
|
169
|
-
function pushStyle(taskId, style, type = 'global', formId = 0, panelId) {
|
|
170
|
-
const el = document.querySelector(`#cg-style-task${taskId} > .cg-style-${type}`);
|
|
171
|
-
if (!el) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
if (type === 'global') {
|
|
175
|
-
el.innerHTML = style;
|
|
176
|
-
}
|
|
177
|
-
else if (type === 'theme' || type === 'control') {
|
|
178
|
-
el.insertAdjacentHTML('beforeend', `<style data-name="${formId}">${style}</style>`);
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
el.insertAdjacentHTML('beforeend', `<style class="cg-style-form${formId}" data-panel="${panelId ? panelId.toString() : ''}">${style}</style>`);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
function removeStyle(taskId, type = 'global', formId = 0, panelId) {
|
|
185
|
-
const styleTask = document.getElementById('cg-style-task' + taskId.toString());
|
|
186
|
-
if (!styleTask) {
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
if (type === 'global') {
|
|
190
|
-
const el = styleTask.querySelector(`.cg-style-global`);
|
|
191
|
-
if (!el) {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
el.innerHTML = '';
|
|
195
|
-
}
|
|
196
|
-
else if (type === 'theme' || type === 'control') {
|
|
197
|
-
if (formId === 0) {
|
|
198
|
-
const el = styleTask.querySelector(`.cg-style-${type}`);
|
|
199
|
-
if (!el) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
el.innerHTML = '';
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
const elist = styleTask.querySelectorAll(`.cg-style-${type} > [data-name='${formId}']`);
|
|
206
|
-
for (let i = 0; i < elist.length; ++i) {
|
|
207
|
-
elist.item(i).remove();
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
const elist = styleTask.querySelectorAll('.cg-style-form' + formId.toString() + (panelId ? '[data-panel="' + panelId.toString() + '"]' : ''));
|
|
213
|
-
for (let i = 0; i < elist.length; ++i) {
|
|
214
|
-
elist.item(i).remove();
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
function getStyleCount(taskId, type) {
|
|
219
|
-
return document.querySelectorAll(`#cg-style-task${taskId} > .cg-style-${type} > style`).length;
|
|
220
|
-
}
|
|
221
|
-
const watchPositionObjects = {};
|
|
222
|
-
let watchPositionIndex = 0;
|
|
223
|
-
function watchPosition(el, cb, immediate = false) {
|
|
224
|
-
if (isWatchPosition(el)) {
|
|
225
|
-
return false;
|
|
226
|
-
}
|
|
227
|
-
if (immediate) {
|
|
228
|
-
try {
|
|
229
|
-
const r = cb({
|
|
230
|
-
'position': false,
|
|
231
|
-
'size': false
|
|
232
|
-
});
|
|
233
|
-
if (r instanceof Promise) {
|
|
234
|
-
r.catch(function (e) {
|
|
235
|
-
console.log('dom.watchPosition', e);
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
catch (e) {
|
|
240
|
-
console.log('dom.watchPosition', e);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
const formWrap = findParentByData(el, 'form-id');
|
|
244
|
-
if (!formWrap) {
|
|
245
|
-
return false;
|
|
246
|
-
}
|
|
247
|
-
const formId = formWrap.dataset.formId;
|
|
248
|
-
const panelWrap = findParentByData(el, 'panel-id');
|
|
249
|
-
const panelId = panelWrap ? panelWrap.dataset.panelId : 'default';
|
|
250
|
-
if (!watchPositionObjects[formId]) {
|
|
251
|
-
watchPositionObjects[formId] = {};
|
|
252
|
-
}
|
|
253
|
-
if (!watchPositionObjects[formId][panelId]) {
|
|
254
|
-
watchPositionObjects[formId][panelId] = {};
|
|
255
|
-
}
|
|
256
|
-
watchPositionObjects[formId][panelId][watchPositionIndex] = {
|
|
257
|
-
'el': el,
|
|
258
|
-
'rect': el.getBoundingClientRect(),
|
|
259
|
-
'handler': cb
|
|
260
|
-
};
|
|
261
|
-
el.dataset.cgPoindex = watchPositionIndex.toString();
|
|
262
|
-
++watchPositionIndex;
|
|
263
|
-
return true;
|
|
264
|
-
}
|
|
265
|
-
function unwatchPosition(el) {
|
|
266
|
-
const index = el.dataset.cgPoindex;
|
|
267
|
-
if (index === undefined) {
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
const formWrap = findParentByData(el, 'form-id');
|
|
271
|
-
if (!formWrap) {
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
const formId = formWrap.dataset.formId;
|
|
275
|
-
const panelWrap = findParentByData(el, 'panel-id');
|
|
276
|
-
const panelId = panelWrap ? panelWrap.dataset.panelId : 'default';
|
|
277
|
-
el.removeAttribute('data-cg-poindex');
|
|
278
|
-
delete watchPositionObjects[formId][panelId][index];
|
|
279
|
-
if (Object.keys(watchPositionObjects[formId][panelId]).length) {
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
delete watchPositionObjects[formId][panelId];
|
|
283
|
-
if (Object.keys(watchPositionObjects[formId]).length) {
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
delete watchPositionObjects[formId];
|
|
287
|
-
}
|
|
288
|
-
function isWatchPosition(el) {
|
|
289
|
-
return el.dataset.cgPoindex ? true : false;
|
|
290
|
-
}
|
|
291
|
-
function clearWatchPosition(formId, panelId) {
|
|
292
|
-
if (!watchPositionObjects[formId]) {
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
for (const panel in watchPositionObjects[formId]) {
|
|
296
|
-
if (panelId) {
|
|
297
|
-
if (panel !== panelId.toString()) {
|
|
298
|
-
continue;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
for (const index in watchPositionObjects[formId][panel]) {
|
|
302
|
-
const item = watchPositionObjects[formId][panel][index];
|
|
303
|
-
item.el.removeAttribute('data-cg-poindex');
|
|
304
|
-
}
|
|
305
|
-
delete watchPositionObjects[formId][panel];
|
|
306
|
-
}
|
|
307
|
-
if (Object.keys(watchPositionObjects[formId]).length) {
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
delete watchPositionObjects[formId];
|
|
311
|
-
}
|
|
312
|
-
const watchSizeList = {};
|
|
313
|
-
function getWatchSizeCount(taskId) {
|
|
314
|
-
if (!taskId) {
|
|
315
|
-
return Object.keys(watchSizeList).length;
|
|
316
|
-
}
|
|
317
|
-
let count = 0;
|
|
318
|
-
for (const id in watchSizeList) {
|
|
319
|
-
if (watchSizeList[id].taskId !== taskId) {
|
|
320
|
-
continue;
|
|
321
|
-
}
|
|
322
|
-
++count;
|
|
323
|
-
}
|
|
324
|
-
return count;
|
|
325
|
-
}
|
|
326
|
-
let watchSizeIndex = 0;
|
|
327
|
-
const resizeObserver = new ResizeObserver(function (entries) {
|
|
328
|
-
for (const entrie of entries) {
|
|
329
|
-
const el = entrie.target;
|
|
330
|
-
if (!document.body.contains(el)) {
|
|
331
|
-
resizeObserver.unobserve(el);
|
|
332
|
-
if (watchSizeList[el.dataset.cgRoindex]) {
|
|
333
|
-
delete watchSizeList[el.dataset.cgRoindex];
|
|
334
|
-
}
|
|
335
|
-
continue;
|
|
336
|
-
}
|
|
337
|
-
const item = watchSizeList[el.dataset.cgRoindex];
|
|
338
|
-
try {
|
|
339
|
-
const r = item.handler();
|
|
340
|
-
if (r instanceof Promise) {
|
|
341
|
-
r.catch(function (e) {
|
|
342
|
-
console.log('ResizeObserver', e);
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
catch (e) {
|
|
347
|
-
console.log('ResizeObserver', e);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
});
|
|
351
|
-
function watchSize(el, cb, immediate = false, taskId) {
|
|
352
|
-
if (isWatchSize(el)) {
|
|
353
|
-
return false;
|
|
354
|
-
}
|
|
355
|
-
if (immediate) {
|
|
356
|
-
try {
|
|
357
|
-
const r = cb();
|
|
358
|
-
if (r instanceof Promise) {
|
|
359
|
-
r.catch(function (e) {
|
|
360
|
-
console.log('dom.watchSize', e);
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
catch (e) {
|
|
365
|
-
console.log('dom.watchSize', e);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
resizeObserver.observe(el);
|
|
369
|
-
watchSizeList[watchSizeIndex] = {
|
|
370
|
-
'el': el,
|
|
371
|
-
'handler': cb,
|
|
372
|
-
'taskId': taskId
|
|
373
|
-
};
|
|
374
|
-
el.dataset.cgRoindex = watchSizeIndex.toString();
|
|
375
|
-
++watchSizeIndex;
|
|
376
|
-
return true;
|
|
377
|
-
}
|
|
378
|
-
function unwatchSize(el, taskId) {
|
|
379
|
-
const index = el.dataset.cgRoindex;
|
|
380
|
-
if (index === undefined) {
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
const item = watchSizeList[index];
|
|
384
|
-
if (taskId && item.taskId !== taskId) {
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
resizeObserver.unobserve(el);
|
|
388
|
-
el.removeAttribute('data-cg-roindex');
|
|
389
|
-
delete watchSizeList[index];
|
|
390
|
-
}
|
|
391
|
-
function isWatchSize(el) {
|
|
392
|
-
return el.dataset.cgRoindex ? true : false;
|
|
393
|
-
}
|
|
394
|
-
function clearWatchSize(taskId) {
|
|
395
|
-
for (const index in watchSizeList) {
|
|
396
|
-
const item = watchSizeList[index];
|
|
397
|
-
if (taskId !== item.taskId) {
|
|
398
|
-
continue;
|
|
399
|
-
}
|
|
400
|
-
resizeObserver.unobserve(item.el);
|
|
401
|
-
item.el.removeAttribute('data-cg-roindex');
|
|
402
|
-
delete watchSizeList[index];
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
const watchList = {};
|
|
406
|
-
function getWatchCount(taskId) {
|
|
407
|
-
if (!taskId) {
|
|
408
|
-
return Object.keys(watchList).length;
|
|
409
|
-
}
|
|
410
|
-
let count = 0;
|
|
411
|
-
for (const id in watchList) {
|
|
412
|
-
if (watchList[id].taskId !== taskId) {
|
|
413
|
-
continue;
|
|
414
|
-
}
|
|
415
|
-
++count;
|
|
416
|
-
}
|
|
417
|
-
return count;
|
|
418
|
-
}
|
|
419
|
-
let watchIndex = 0;
|
|
420
|
-
function watch(el, cb, mode = 'default', immediate = false, taskId) {
|
|
421
|
-
if (isWatch(el)) {
|
|
422
|
-
return false;
|
|
423
|
-
}
|
|
424
|
-
if (immediate) {
|
|
425
|
-
try {
|
|
426
|
-
const r = cb([]);
|
|
427
|
-
if (r instanceof Promise) {
|
|
428
|
-
r.catch(function (e) {
|
|
429
|
-
console.log('dom.watch', e);
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
catch (e) {
|
|
434
|
-
console.log('dom.watch', e);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
const index = watchIndex;
|
|
438
|
-
let moi;
|
|
439
|
-
switch (mode) {
|
|
440
|
-
case 'child': {
|
|
441
|
-
moi = {
|
|
442
|
-
'childList': true
|
|
443
|
-
};
|
|
444
|
-
break;
|
|
445
|
-
}
|
|
446
|
-
case 'childsub': {
|
|
447
|
-
moi = {
|
|
448
|
-
'childList': true,
|
|
449
|
-
'subtree': true
|
|
450
|
-
};
|
|
451
|
-
break;
|
|
452
|
-
}
|
|
453
|
-
case 'style': {
|
|
454
|
-
moi = {
|
|
455
|
-
'attributeFilter': ['style', 'class'],
|
|
456
|
-
'attributeOldValue': true,
|
|
457
|
-
'attributes': true
|
|
458
|
-
};
|
|
459
|
-
break;
|
|
460
|
-
}
|
|
461
|
-
case 'text': {
|
|
462
|
-
moi = {
|
|
463
|
-
'characterData': true,
|
|
464
|
-
'childList': true,
|
|
465
|
-
'subtree': true
|
|
466
|
-
};
|
|
467
|
-
break;
|
|
468
|
-
}
|
|
469
|
-
default: {
|
|
470
|
-
moi = {
|
|
471
|
-
'attributeFilter': ['style', 'class'],
|
|
472
|
-
'attributeOldValue': true,
|
|
473
|
-
'attributes': true,
|
|
474
|
-
'characterData': true,
|
|
475
|
-
'childList': true,
|
|
476
|
-
'subtree': true
|
|
477
|
-
};
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
const mo = new MutationObserver((mutations) => {
|
|
481
|
-
if (!document.body.contains(el)) {
|
|
482
|
-
mo.disconnect();
|
|
483
|
-
if (watchList[index]) {
|
|
484
|
-
delete watchList[index];
|
|
485
|
-
}
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
try {
|
|
489
|
-
const r = cb(mutations);
|
|
490
|
-
if (r instanceof Promise) {
|
|
491
|
-
r.catch(function (e) {
|
|
492
|
-
console.log('dom.watch', e);
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
catch (e) {
|
|
497
|
-
console.log('dom.watch', e);
|
|
498
|
-
}
|
|
499
|
-
});
|
|
500
|
-
mo.observe(el, moi);
|
|
501
|
-
watchList[index] = {
|
|
502
|
-
'el': el,
|
|
503
|
-
'mo': mo,
|
|
504
|
-
'taskId': taskId
|
|
505
|
-
};
|
|
506
|
-
el.dataset.cgMoindex = index.toString();
|
|
507
|
-
++watchIndex;
|
|
508
|
-
return true;
|
|
509
|
-
}
|
|
510
|
-
function unwatch(el, taskId) {
|
|
511
|
-
const index = el.dataset.cgMoindex;
|
|
512
|
-
if (index === undefined) {
|
|
513
|
-
return;
|
|
514
|
-
}
|
|
515
|
-
const item = watchList[index];
|
|
516
|
-
if (taskId && item.taskId !== taskId) {
|
|
517
|
-
return;
|
|
518
|
-
}
|
|
519
|
-
el.removeAttribute('data-cg-moindex');
|
|
520
|
-
watchList[index].mo.disconnect();
|
|
521
|
-
delete watchList[index];
|
|
522
|
-
}
|
|
523
|
-
function isWatch(el) {
|
|
524
|
-
return el.dataset.cgMoindex ? true : false;
|
|
525
|
-
}
|
|
526
|
-
function clearWatch(taskId) {
|
|
527
|
-
for (const index in watchList) {
|
|
528
|
-
const item = watchList[index];
|
|
529
|
-
if (taskId !== item.taskId) {
|
|
530
|
-
continue;
|
|
531
|
-
}
|
|
532
|
-
item.el.removeAttribute('data-cg-moindex');
|
|
533
|
-
item.mo.disconnect();
|
|
534
|
-
delete watchList[index];
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
const watchCgTimerHandler = function () {
|
|
538
|
-
for (const index in watchSizeList) {
|
|
539
|
-
const item = watchSizeList[index];
|
|
540
|
-
if (document.body.contains(item.el)) {
|
|
541
|
-
continue;
|
|
542
|
-
}
|
|
543
|
-
delete watchSizeList[index];
|
|
544
|
-
}
|
|
545
|
-
for (const index in watchList) {
|
|
546
|
-
const item = watchList[index];
|
|
547
|
-
if (document.body.contains(item.el)) {
|
|
548
|
-
continue;
|
|
549
|
-
}
|
|
550
|
-
delete watchList[index];
|
|
551
|
-
}
|
|
552
|
-
window.setTimeout(watchCgTimerHandler, 1000 * 60 * 7);
|
|
553
|
-
};
|
|
554
|
-
watchCgTimerHandler();
|
|
555
|
-
const watchStyleList = {};
|
|
556
|
-
let watchStyleIndex = 0;
|
|
557
|
-
function watchStyle(el, name, cb, immediate = false) {
|
|
558
|
-
if (typeof name === 'string') {
|
|
559
|
-
name = [name];
|
|
560
|
-
}
|
|
561
|
-
const formWrap = findParentByData(el, 'form-id');
|
|
562
|
-
if (!formWrap) {
|
|
563
|
-
return;
|
|
564
|
-
}
|
|
565
|
-
const formId = formWrap.dataset.formId;
|
|
566
|
-
const panelWrap = findParentByData(el, 'panel-id');
|
|
567
|
-
const panelId = panelWrap ? panelWrap.dataset.panelId : 'default';
|
|
568
|
-
const index = el.dataset.cgStyleindex;
|
|
569
|
-
if (index) {
|
|
570
|
-
const item = watchStyleList[formId][panelId][index];
|
|
571
|
-
for (const n of name) {
|
|
572
|
-
if (!item.names[n]) {
|
|
573
|
-
item.names[n] = {
|
|
574
|
-
'val': item.sd[n],
|
|
575
|
-
'cb': [cb]
|
|
576
|
-
};
|
|
577
|
-
}
|
|
578
|
-
else {
|
|
579
|
-
item.names[n].cb.push(cb);
|
|
580
|
-
}
|
|
581
|
-
if (immediate) {
|
|
582
|
-
cb(n, item.sd[n], '');
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
return;
|
|
586
|
-
}
|
|
587
|
-
if (!watchStyleList[formId]) {
|
|
588
|
-
watchStyleList[formId] = {};
|
|
589
|
-
}
|
|
590
|
-
if (!watchStyleList[formId][panelId]) {
|
|
591
|
-
watchStyleList[formId][panelId] = {};
|
|
592
|
-
}
|
|
593
|
-
const sd = getComputedStyle(el);
|
|
594
|
-
watchStyleList[formId][panelId][watchStyleIndex] = {
|
|
595
|
-
'el': el,
|
|
596
|
-
'sd': sd,
|
|
597
|
-
'names': {}
|
|
598
|
-
};
|
|
599
|
-
const item = watchStyleList[formId][panelId][watchStyleIndex];
|
|
600
|
-
for (const n of name) {
|
|
601
|
-
item.names[n] = {
|
|
602
|
-
'val': item.sd[n],
|
|
603
|
-
'cb': [cb]
|
|
604
|
-
};
|
|
605
|
-
if (immediate) {
|
|
606
|
-
cb(n, item.sd[n], '');
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
el.dataset.cgStyleindex = watchStyleIndex.toString();
|
|
610
|
-
++watchStyleIndex;
|
|
611
|
-
}
|
|
612
|
-
function isWatchStyle(el) {
|
|
613
|
-
return el.dataset.cgStyleindex ? true : false;
|
|
614
|
-
}
|
|
615
|
-
function clearWatchStyle(formId, panelId) {
|
|
616
|
-
if (!watchStyleList[formId]) {
|
|
617
|
-
return;
|
|
618
|
-
}
|
|
619
|
-
for (const panel in watchStyleList[formId]) {
|
|
620
|
-
if (panelId) {
|
|
621
|
-
if (panel !== panelId.toString()) {
|
|
622
|
-
continue;
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
for (const index in watchStyleList[formId][panel]) {
|
|
626
|
-
const item = watchStyleList[formId][panel][index];
|
|
627
|
-
item.el.removeAttribute('data-cg-styleindex');
|
|
628
|
-
}
|
|
629
|
-
delete watchStyleList[formId][panel];
|
|
630
|
-
}
|
|
631
|
-
if (Object.keys(watchStyleList[formId]).length) {
|
|
632
|
-
return;
|
|
633
|
-
}
|
|
634
|
-
delete watchStyleList[formId];
|
|
635
|
-
}
|
|
636
|
-
const watchPropertyObjects = {};
|
|
637
|
-
let watchPropertyIndex = 0;
|
|
638
|
-
function watchProperty(el, name, cb, immediate = false) {
|
|
639
|
-
if (typeof name === 'string') {
|
|
640
|
-
name = [name];
|
|
641
|
-
}
|
|
642
|
-
const formWrap = findParentByData(el, 'form-id');
|
|
643
|
-
if (!formWrap) {
|
|
644
|
-
return;
|
|
645
|
-
}
|
|
646
|
-
const formId = formWrap.dataset.formId;
|
|
647
|
-
const panelWrap = findParentByData(el, 'panel-id');
|
|
648
|
-
const panelId = panelWrap ? panelWrap.dataset.panelId : 'default';
|
|
649
|
-
const index = el.dataset.cgPropertyindex;
|
|
650
|
-
if (index) {
|
|
651
|
-
const item = watchPropertyObjects[formId][panelId][index];
|
|
652
|
-
for (const n of name) {
|
|
653
|
-
if (!item.names[n]) {
|
|
654
|
-
item.names[n] = {
|
|
655
|
-
'val': item.el[n],
|
|
656
|
-
'cb': [cb]
|
|
657
|
-
};
|
|
658
|
-
}
|
|
659
|
-
else {
|
|
660
|
-
item.names[n].cb.push(cb);
|
|
661
|
-
}
|
|
662
|
-
if (immediate) {
|
|
663
|
-
cb(n, item.el[n]);
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
return;
|
|
667
|
-
}
|
|
668
|
-
if (!watchPropertyObjects[formId]) {
|
|
669
|
-
watchPropertyObjects[formId] = {};
|
|
670
|
-
}
|
|
671
|
-
if (!watchPropertyObjects[formId][panelId]) {
|
|
672
|
-
watchPropertyObjects[formId][panelId] = {};
|
|
673
|
-
}
|
|
674
|
-
watchPropertyObjects[formId][panelId][watchPropertyIndex] = {
|
|
675
|
-
'el': el,
|
|
676
|
-
'names': {}
|
|
677
|
-
};
|
|
678
|
-
const item = watchPropertyObjects[formId][panelId][watchPropertyIndex];
|
|
679
|
-
for (const n of name) {
|
|
680
|
-
item.names[n] = {
|
|
681
|
-
'val': item.el[n],
|
|
682
|
-
'cb': [cb]
|
|
683
|
-
};
|
|
684
|
-
if (immediate) {
|
|
685
|
-
cb(n, item.el[n]);
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
el.dataset.cgPropertyindex = watchPropertyIndex.toString();
|
|
689
|
-
++watchPropertyIndex;
|
|
690
|
-
}
|
|
691
|
-
function isWatchProperty(el) {
|
|
692
|
-
return el.dataset.cgPropertyindex ? true : false;
|
|
693
|
-
}
|
|
694
|
-
function clearWatchProperty(formId, panelId) {
|
|
695
|
-
if (!watchPropertyObjects[formId]) {
|
|
696
|
-
return;
|
|
697
|
-
}
|
|
698
|
-
for (const panel in watchPropertyObjects[formId]) {
|
|
699
|
-
if (panelId) {
|
|
700
|
-
if (panel !== panelId.toString()) {
|
|
701
|
-
continue;
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
for (const index in watchPropertyObjects[formId][panel]) {
|
|
705
|
-
const item = watchPropertyObjects[formId][panel][index];
|
|
706
|
-
item.el.removeAttribute('data-cg-propertyindex');
|
|
707
|
-
}
|
|
708
|
-
delete watchPropertyObjects[formId][panel];
|
|
709
|
-
}
|
|
710
|
-
if (Object.keys(watchPropertyObjects[formId]).length) {
|
|
711
|
-
return;
|
|
712
|
-
}
|
|
713
|
-
delete watchPropertyObjects[formId];
|
|
714
|
-
}
|
|
715
|
-
function getWatchInfo() {
|
|
716
|
-
var _a, _b;
|
|
717
|
-
const rtn = {
|
|
718
|
-
'formId': 0,
|
|
719
|
-
'default': {},
|
|
720
|
-
'panels': {}
|
|
721
|
-
};
|
|
722
|
-
const formId = form.getFocus();
|
|
723
|
-
if (!formId) {
|
|
724
|
-
return rtn;
|
|
725
|
-
}
|
|
726
|
-
rtn.formId = formId;
|
|
727
|
-
const panelIds = form.getActivePanel(formId);
|
|
728
|
-
const handler = (item, type, panelId) => {
|
|
729
|
-
var _a, _b, _c;
|
|
730
|
-
if (panelId) {
|
|
731
|
-
if (!rtn.panels[panelId]) {
|
|
732
|
-
rtn.panels[panelId] = {};
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
const ritem = panelId ? rtn.panels[panelId] : rtn.default;
|
|
736
|
-
const cname = (_c = (_a = item.el.dataset.cgControl) !== null && _a !== void 0 ? _a : (_b = findParentByData(item.el, 'cg-control')) === null || _b === void 0 ? void 0 : _b.dataset.cgControl) !== null && _c !== void 0 ? _c : 'unknown';
|
|
737
|
-
if (!ritem[cname]) {
|
|
738
|
-
ritem[cname] = {
|
|
739
|
-
'style': {
|
|
740
|
-
'count': 0,
|
|
741
|
-
'list': []
|
|
742
|
-
},
|
|
743
|
-
'property': {
|
|
744
|
-
'count': 0,
|
|
745
|
-
'list': []
|
|
746
|
-
},
|
|
747
|
-
'position': {
|
|
748
|
-
'count': 0
|
|
749
|
-
}
|
|
750
|
-
};
|
|
751
|
-
}
|
|
752
|
-
++ritem[cname][type].count;
|
|
753
|
-
if (item.names && type !== 'position') {
|
|
754
|
-
for (const name in item.names) {
|
|
755
|
-
if (ritem[cname][type].list.includes(name)) {
|
|
756
|
-
continue;
|
|
757
|
-
}
|
|
758
|
-
ritem[cname][type].list.push(name);
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
};
|
|
762
|
-
if (watchStyleList[formId]) {
|
|
763
|
-
if (watchStyleList[formId].default) {
|
|
764
|
-
for (const index in watchStyleList[formId].default) {
|
|
765
|
-
handler(watchStyleList[formId].default[index], 'style');
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
for (const id of panelIds) {
|
|
769
|
-
if (watchStyleList[formId][id]) {
|
|
770
|
-
for (const index in watchStyleList[formId][id]) {
|
|
771
|
-
handler(watchStyleList[formId][id][index], 'style', id.toString());
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
if (watchPropertyObjects[formId]) {
|
|
777
|
-
if (watchPropertyObjects[formId].default) {
|
|
778
|
-
for (const index in watchPropertyObjects[formId].default) {
|
|
779
|
-
handler(watchPropertyObjects[formId].default[index], 'property');
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
for (const id of panelIds) {
|
|
783
|
-
if ((_a = watchPropertyObjects[formId]) === null || _a === void 0 ? void 0 : _a[id]) {
|
|
784
|
-
for (const index in watchPropertyObjects[formId][id]) {
|
|
785
|
-
handler(watchPropertyObjects[formId][id][index], 'property', id.toString());
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
if (watchPositionObjects[formId]) {
|
|
791
|
-
if (watchPositionObjects[formId].default) {
|
|
792
|
-
for (const index in watchPositionObjects[formId].default) {
|
|
793
|
-
handler(watchPositionObjects[formId].default[index], 'position');
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
for (const id of panelIds) {
|
|
797
|
-
if ((_b = watchPositionObjects[formId]) === null || _b === void 0 ? void 0 : _b[id]) {
|
|
798
|
-
for (const index in watchPositionObjects[formId][id]) {
|
|
799
|
-
handler(watchPositionObjects[formId][id][index], 'position', id.toString());
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
return rtn;
|
|
805
|
-
}
|
|
806
|
-
let watchTimer = 0;
|
|
807
|
-
const watchTimerHandler = function () {
|
|
808
|
-
if (form.getFocus) {
|
|
809
|
-
const formId = form.getFocus();
|
|
810
|
-
if (formId) {
|
|
811
|
-
const panelIds = form.getActivePanel(formId);
|
|
812
|
-
if (watchStyleList[formId]) {
|
|
813
|
-
const handler = (item, panelId, index) => {
|
|
814
|
-
if (!document.body.contains(item.el)) {
|
|
815
|
-
delete watchStyleList[formId][panelId][index];
|
|
816
|
-
if (!Object.keys(watchStyleList[formId][panelId]).length) {
|
|
817
|
-
delete watchStyleList[formId][panelId];
|
|
818
|
-
}
|
|
819
|
-
if (!Object.keys(watchStyleList[formId]).length) {
|
|
820
|
-
delete watchStyleList[formId];
|
|
821
|
-
}
|
|
822
|
-
return;
|
|
823
|
-
}
|
|
824
|
-
for (const name in item.names) {
|
|
825
|
-
if (item.sd[name] === item.names[name].val) {
|
|
826
|
-
continue;
|
|
827
|
-
}
|
|
828
|
-
const old = item.names[name].val;
|
|
829
|
-
item.names[name].val = item.sd[name];
|
|
830
|
-
for (const cb of item.names[name].cb) {
|
|
831
|
-
cb(name, item.sd[name], old);
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
};
|
|
835
|
-
if (watchStyleList[formId].default) {
|
|
836
|
-
for (const index in watchStyleList[formId].default) {
|
|
837
|
-
handler(watchStyleList[formId].default[index], 'default', index);
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
for (const id of panelIds) {
|
|
841
|
-
if (watchStyleList[formId][id]) {
|
|
842
|
-
for (const index in watchStyleList[formId][id]) {
|
|
843
|
-
handler(watchStyleList[formId][id][index], id.toString(), index);
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
if (watchPropertyObjects[formId]) {
|
|
849
|
-
const handler = (item, panelId, index) => {
|
|
850
|
-
if (!document.body.contains(item.el)) {
|
|
851
|
-
delete watchPropertyObjects[formId][panelId][index];
|
|
852
|
-
if (!Object.keys(watchPropertyObjects[formId][panelId]).length) {
|
|
853
|
-
delete watchPropertyObjects[formId][panelId];
|
|
854
|
-
}
|
|
855
|
-
if (!Object.keys(watchPropertyObjects[formId]).length) {
|
|
856
|
-
delete watchPropertyObjects[formId];
|
|
857
|
-
}
|
|
858
|
-
return;
|
|
859
|
-
}
|
|
860
|
-
for (const name in item.names) {
|
|
861
|
-
if (item.el[name] === item.names[name].val) {
|
|
862
|
-
continue;
|
|
863
|
-
}
|
|
864
|
-
item.names[name].val = item.el[name];
|
|
865
|
-
for (const cb of item.names[name].cb) {
|
|
866
|
-
cb(name, item.el[name]);
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
};
|
|
870
|
-
if (watchPropertyObjects[formId].default) {
|
|
871
|
-
for (const index in watchPropertyObjects[formId].default) {
|
|
872
|
-
handler(watchPropertyObjects[formId].default[index], 'default', index);
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
for (const id of panelIds) {
|
|
876
|
-
if (watchPropertyObjects[formId][id]) {
|
|
877
|
-
for (const index in watchPropertyObjects[formId][id]) {
|
|
878
|
-
handler(watchPropertyObjects[formId][id][index], id.toString(), index);
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
if (watchPositionObjects[formId]) {
|
|
884
|
-
const handler = (item, panelId, index) => {
|
|
885
|
-
if (!document.body.contains(item.el)) {
|
|
886
|
-
delete watchPositionObjects[formId][panelId][index];
|
|
887
|
-
if (!Object.keys(watchPositionObjects[formId][panelId]).length) {
|
|
888
|
-
delete watchPositionObjects[formId][panelId];
|
|
889
|
-
}
|
|
890
|
-
if (!Object.keys(watchPositionObjects[formId]).length) {
|
|
891
|
-
delete watchPositionObjects[formId];
|
|
892
|
-
}
|
|
893
|
-
return;
|
|
894
|
-
}
|
|
895
|
-
const rect = item.el.getBoundingClientRect();
|
|
896
|
-
let position = false;
|
|
897
|
-
let size = false;
|
|
898
|
-
if (item.rect.left !== rect.left || item.rect.top !== rect.top) {
|
|
899
|
-
position = true;
|
|
900
|
-
}
|
|
901
|
-
if (item.rect.width !== rect.width || item.rect.height !== rect.height) {
|
|
902
|
-
size = true;
|
|
903
|
-
}
|
|
904
|
-
if (position || size) {
|
|
905
|
-
item.handler({
|
|
906
|
-
'position': position,
|
|
907
|
-
'size': size
|
|
908
|
-
});
|
|
909
|
-
}
|
|
910
|
-
watchPositionObjects[formId][panelId][index].rect = rect;
|
|
911
|
-
};
|
|
912
|
-
if (watchPositionObjects[formId].default) {
|
|
913
|
-
for (const index in watchPositionObjects[formId].default) {
|
|
914
|
-
handler(watchPositionObjects[formId].default[index], 'default', index);
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
for (const id of panelIds) {
|
|
918
|
-
if (watchPositionObjects[formId][id]) {
|
|
919
|
-
for (const index in watchPositionObjects[formId][id]) {
|
|
920
|
-
handler(watchPositionObjects[formId][id][index], id.toString(), index);
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
watchTimer = requestAnimationFrame(watchTimerHandler);
|
|
928
|
-
};
|
|
929
|
-
watchTimerHandler();
|
|
930
|
-
function bindClick(e, handler) {
|
|
931
|
-
if ((e instanceof MouseEvent) && (e.button > 0)) {
|
|
932
|
-
return;
|
|
933
|
-
}
|
|
934
|
-
const x = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
|
|
935
|
-
const y = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
|
|
936
|
-
const time = Date.now();
|
|
937
|
-
bindDown(e, {
|
|
938
|
-
up: (ne) => {
|
|
939
|
-
if (Date.now() - time >= 250) {
|
|
940
|
-
return;
|
|
941
|
-
}
|
|
942
|
-
const nx = ne instanceof MouseEvent ? ne.clientX : ne.changedTouches[0].clientX;
|
|
943
|
-
const ny = ne instanceof MouseEvent ? ne.clientY : ne.changedTouches[0].clientY;
|
|
944
|
-
if (nx === x && ny === y) {
|
|
945
|
-
handler(ne, nx, ny);
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
});
|
|
949
|
-
}
|
|
950
|
-
const lastDblClickData = {
|
|
951
|
-
'time': 0,
|
|
952
|
-
'x': 0,
|
|
953
|
-
'y': 0
|
|
954
|
-
};
|
|
955
|
-
function bindDblClick(e, handler) {
|
|
956
|
-
bindClick(e, (ne, x, y) => {
|
|
957
|
-
const now = Date.now();
|
|
958
|
-
if (now - lastDblClickData.time <= 300) {
|
|
959
|
-
const xx = Math.abs(x - lastDblClickData.x);
|
|
960
|
-
const xy = Math.abs(y - lastDblClickData.y);
|
|
961
|
-
if (xx < 10 && xy < 10) {
|
|
962
|
-
handler(ne, x, y);
|
|
963
|
-
lastDblClickData.time = 0;
|
|
964
|
-
lastDblClickData.x = 0;
|
|
965
|
-
lastDblClickData.y = 0;
|
|
966
|
-
return;
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
lastDblClickData.time = now;
|
|
970
|
-
lastDblClickData.x = x;
|
|
971
|
-
lastDblClickData.y = y;
|
|
972
|
-
});
|
|
973
|
-
}
|
|
974
|
-
function bindDown(oe, opt) {
|
|
975
|
-
var _a;
|
|
976
|
-
if (hasTouchButMouse(oe)) {
|
|
977
|
-
return;
|
|
978
|
-
}
|
|
979
|
-
let ox, oy;
|
|
980
|
-
if (oe instanceof MouseEvent) {
|
|
981
|
-
ox = oe.clientX;
|
|
982
|
-
oy = oe.clientY;
|
|
983
|
-
}
|
|
984
|
-
else {
|
|
985
|
-
ox = oe.touches[0].clientX;
|
|
986
|
-
oy = oe.touches[0].clientY;
|
|
987
|
-
}
|
|
988
|
-
let isStart = false;
|
|
989
|
-
let end = undefined;
|
|
990
|
-
const move = function (e) {
|
|
991
|
-
if (!e.target || !document.body.contains(e.target) && e.cancelable) {
|
|
992
|
-
e.preventDefault();
|
|
993
|
-
}
|
|
994
|
-
let dir = 'top';
|
|
995
|
-
const x = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
|
|
996
|
-
const y = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
|
|
997
|
-
if (x === ox && y === oy) {
|
|
998
|
-
return;
|
|
999
|
-
}
|
|
1000
|
-
const xx = x - ox;
|
|
1001
|
-
const xy = y - oy;
|
|
1002
|
-
if (Math.abs(xy) > Math.abs(xx)) {
|
|
1003
|
-
if (xy < 0) {
|
|
1004
|
-
dir = 'top';
|
|
1005
|
-
}
|
|
1006
|
-
else {
|
|
1007
|
-
dir = 'bottom';
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
else {
|
|
1011
|
-
if (xx < 0) {
|
|
1012
|
-
dir = 'left';
|
|
1013
|
-
}
|
|
1014
|
-
else {
|
|
1015
|
-
dir = 'right';
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
ox = x;
|
|
1019
|
-
oy = y;
|
|
1020
|
-
if (!isStart) {
|
|
1021
|
-
isStart = true;
|
|
1022
|
-
if (opt.start && (opt.start(e) === false)) {
|
|
1023
|
-
if (e instanceof MouseEvent) {
|
|
1024
|
-
window.removeEventListener('mousemove', move);
|
|
1025
|
-
window.removeEventListener('mouseup', end);
|
|
1026
|
-
}
|
|
1027
|
-
else {
|
|
1028
|
-
oe.target.removeEventListener('touchmove', move);
|
|
1029
|
-
oe.target.removeEventListener('touchend', end);
|
|
1030
|
-
oe.target.removeEventListener('touchcancel', end);
|
|
1031
|
-
}
|
|
1032
|
-
return;
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
if (opt.move && (opt.move(e, dir) === false)) {
|
|
1036
|
-
if (e instanceof MouseEvent) {
|
|
1037
|
-
window.removeEventListener('mousemove', move);
|
|
1038
|
-
window.removeEventListener('mouseup', end);
|
|
1039
|
-
}
|
|
1040
|
-
else {
|
|
1041
|
-
if (oe.target) {
|
|
1042
|
-
oe.target.removeEventListener('touchmove', move);
|
|
1043
|
-
oe.target.removeEventListener('touchend', end);
|
|
1044
|
-
oe.target.removeEventListener('touchcancel', end);
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
return;
|
|
1048
|
-
}
|
|
1049
|
-
};
|
|
1050
|
-
end = function (e) {
|
|
1051
|
-
var _a, _b;
|
|
1052
|
-
if (e instanceof MouseEvent) {
|
|
1053
|
-
window.removeEventListener('mousemove', move);
|
|
1054
|
-
window.removeEventListener('mouseup', end);
|
|
1055
|
-
}
|
|
1056
|
-
else {
|
|
1057
|
-
if (oe.target) {
|
|
1058
|
-
oe.target.removeEventListener('touchmove', move);
|
|
1059
|
-
oe.target.removeEventListener('touchend', end);
|
|
1060
|
-
oe.target.removeEventListener('touchcancel', end);
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
(_a = opt.up) === null || _a === void 0 ? void 0 : _a.call(opt, e);
|
|
1064
|
-
if (isStart) {
|
|
1065
|
-
(_b = opt.end) === null || _b === void 0 ? void 0 : _b.call(opt, e);
|
|
1066
|
-
}
|
|
1067
|
-
};
|
|
1068
|
-
if (oe instanceof MouseEvent) {
|
|
1069
|
-
window.addEventListener('mousemove', move, {
|
|
1070
|
-
'passive': false
|
|
1071
|
-
});
|
|
1072
|
-
window.addEventListener('mouseup', end);
|
|
1073
|
-
}
|
|
1074
|
-
else {
|
|
1075
|
-
oe.target.addEventListener('touchmove', move, {
|
|
1076
|
-
'passive': false
|
|
1077
|
-
});
|
|
1078
|
-
oe.target.addEventListener('touchend', end);
|
|
1079
|
-
oe.target.addEventListener('touchcancel', end);
|
|
1080
|
-
}
|
|
1081
|
-
(_a = opt.down) === null || _a === void 0 ? void 0 : _a.call(opt, oe);
|
|
1082
|
-
}
|
|
1083
|
-
function bindScale(oe, handler) {
|
|
1084
|
-
var _a, _b, _c, _d;
|
|
1085
|
-
const el = oe.currentTarget;
|
|
1086
|
-
if (!el) {
|
|
1087
|
-
return;
|
|
1088
|
-
}
|
|
1089
|
-
if (oe instanceof TouchEvent) {
|
|
1090
|
-
if (oe.type === 'touchend') {
|
|
1091
|
-
if (oe.touches.length) {
|
|
1092
|
-
return;
|
|
1093
|
-
}
|
|
1094
|
-
el.removeAttribute('data-cg-scale');
|
|
1095
|
-
return;
|
|
1096
|
-
}
|
|
1097
|
-
const ex = [oe.touches[0].clientX, (_b = (_a = oe.touches[1]) === null || _a === void 0 ? void 0 : _a.clientX) !== null && _b !== void 0 ? _b : -1000];
|
|
1098
|
-
const ey = [oe.touches[0].clientY, (_d = (_c = oe.touches[1]) === null || _c === void 0 ? void 0 : _c.clientY) !== null && _d !== void 0 ? _d : -1000];
|
|
1099
|
-
let ndis = 0;
|
|
1100
|
-
const epos = {
|
|
1101
|
-
'x': ex[0],
|
|
1102
|
-
'y': ey[0]
|
|
1103
|
-
};
|
|
1104
|
-
if (ex[1] !== -1000) {
|
|
1105
|
-
const nx = ex[0] - ex[1];
|
|
1106
|
-
const ny = ey[0] - ey[1];
|
|
1107
|
-
ndis = Math.hypot(nx, ny);
|
|
1108
|
-
const cnx = (ex[0] + ex[1]) / 2;
|
|
1109
|
-
const cny = (ey[0] + ey[1]) / 2;
|
|
1110
|
-
epos['x'] = cnx;
|
|
1111
|
-
epos['y'] = cny;
|
|
1112
|
-
}
|
|
1113
|
-
if (el.dataset.cgScale === undefined) {
|
|
1114
|
-
el.dataset.cgScale = JSON.stringify({
|
|
1115
|
-
'dis': ndis,
|
|
1116
|
-
'x': ex,
|
|
1117
|
-
'y': ey,
|
|
1118
|
-
'pos': epos
|
|
1119
|
-
});
|
|
1120
|
-
return;
|
|
1121
|
-
}
|
|
1122
|
-
const d = JSON.parse(el.dataset.cgScale);
|
|
1123
|
-
let notchange = false;
|
|
1124
|
-
if (ex[1] !== -1000) {
|
|
1125
|
-
if (d.x[1] === -1000) {
|
|
1126
|
-
notchange = true;
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
else {
|
|
1130
|
-
if (d.x[1] !== -1000) {
|
|
1131
|
-
notchange = true;
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
const scale = ndis > 0 && d.dis > 0 ? ndis / d.dis : 1;
|
|
1135
|
-
handler(oe, scale, {
|
|
1136
|
-
'x': notchange ? 0 : epos['x'] - d.pos['x'],
|
|
1137
|
-
'y': notchange ? 0 : epos['y'] - d.pos['y']
|
|
1138
|
-
});
|
|
1139
|
-
el.dataset.cgScale = JSON.stringify({
|
|
1140
|
-
'dis': ndis,
|
|
1141
|
-
'x': ex,
|
|
1142
|
-
'y': ey,
|
|
1143
|
-
'pos': epos
|
|
1144
|
-
});
|
|
1145
|
-
return;
|
|
1146
|
-
}
|
|
1147
|
-
if (oe instanceof WheelEvent) {
|
|
1148
|
-
if (!oe.deltaY) {
|
|
1149
|
-
return;
|
|
1150
|
-
}
|
|
1151
|
-
const delta = Math.abs(oe.deltaY);
|
|
1152
|
-
const zoomFactor = delta * (delta > 50 ? 0.0015 : 0.003);
|
|
1153
|
-
handler(oe, oe.deltaY < 0 ? 1 + zoomFactor : 1 - zoomFactor, {
|
|
1154
|
-
'x': 0,
|
|
1155
|
-
'y': 0
|
|
1156
|
-
});
|
|
1157
|
-
return;
|
|
1158
|
-
}
|
|
1159
|
-
bindMove(oe, {
|
|
1160
|
-
'move': (e, opt) => {
|
|
1161
|
-
handler(oe, 1, {
|
|
1162
|
-
'x': opt.ox,
|
|
1163
|
-
'y': opt.oy
|
|
1164
|
-
});
|
|
1165
|
-
}
|
|
1166
|
-
});
|
|
1167
|
-
}
|
|
1168
|
-
const gestureWheel = {
|
|
1169
|
-
'last': 0,
|
|
1170
|
-
'offset': 0,
|
|
1171
|
-
'done': false,
|
|
1172
|
-
'timer': 0,
|
|
1173
|
-
'firstTimer': false,
|
|
1174
|
-
'dir': ''
|
|
1175
|
-
};
|
|
1176
|
-
function bindGesture(oe, before, handler) {
|
|
1177
|
-
const el = oe.currentTarget;
|
|
1178
|
-
if (!el) {
|
|
1179
|
-
return;
|
|
1180
|
-
}
|
|
1181
|
-
const rect = el.getBoundingClientRect();
|
|
1182
|
-
if ((oe instanceof MouseEvent || oe instanceof TouchEvent) && !(oe instanceof WheelEvent)) {
|
|
1183
|
-
let offset = 0;
|
|
1184
|
-
let origin = 0;
|
|
1185
|
-
let first = 1;
|
|
1186
|
-
let dir = 'top';
|
|
1187
|
-
bindDown(oe, {
|
|
1188
|
-
move: (e, d) => {
|
|
1189
|
-
if (first < 0) {
|
|
1190
|
-
if (first > -30) {
|
|
1191
|
-
const rtn = before(e, dir);
|
|
1192
|
-
if (rtn === 1) {
|
|
1193
|
-
e.stopPropagation();
|
|
1194
|
-
e.preventDefault();
|
|
1195
|
-
}
|
|
1196
|
-
else if (rtn === -1) {
|
|
1197
|
-
e.stopPropagation();
|
|
1198
|
-
}
|
|
1199
|
-
--first;
|
|
1200
|
-
}
|
|
1201
|
-
return;
|
|
1202
|
-
}
|
|
1203
|
-
if (first === 1) {
|
|
1204
|
-
first = 0;
|
|
1205
|
-
switch (d) {
|
|
1206
|
-
case 'top': {
|
|
1207
|
-
dir = 'bottom';
|
|
1208
|
-
break;
|
|
1209
|
-
}
|
|
1210
|
-
case 'bottom': {
|
|
1211
|
-
dir = 'top';
|
|
1212
|
-
break;
|
|
1213
|
-
}
|
|
1214
|
-
case 'left': {
|
|
1215
|
-
dir = 'right';
|
|
1216
|
-
break;
|
|
1217
|
-
}
|
|
1218
|
-
default: {
|
|
1219
|
-
dir = 'left';
|
|
1220
|
-
}
|
|
1221
|
-
}
|
|
1222
|
-
const rtn = before(e, dir);
|
|
1223
|
-
if (rtn === 1) {
|
|
1224
|
-
e.stopPropagation();
|
|
1225
|
-
e.preventDefault();
|
|
1226
|
-
}
|
|
1227
|
-
else {
|
|
1228
|
-
if (rtn === -1) {
|
|
1229
|
-
e.stopPropagation();
|
|
1230
|
-
}
|
|
1231
|
-
first = -1;
|
|
1232
|
-
return;
|
|
1233
|
-
}
|
|
1234
|
-
switch (dir) {
|
|
1235
|
-
case 'top':
|
|
1236
|
-
case 'bottom': {
|
|
1237
|
-
origin = oe instanceof MouseEvent ? oe.clientY : oe.touches[0].clientY;
|
|
1238
|
-
break;
|
|
1239
|
-
}
|
|
1240
|
-
default: {
|
|
1241
|
-
origin = oe instanceof MouseEvent ? oe.clientX : oe.touches[0].clientX;
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
let pos = 0;
|
|
1246
|
-
switch (dir) {
|
|
1247
|
-
case 'top':
|
|
1248
|
-
case 'bottom': {
|
|
1249
|
-
pos = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
|
|
1250
|
-
if (dir === 'top') {
|
|
1251
|
-
offset = pos - origin;
|
|
1252
|
-
}
|
|
1253
|
-
else {
|
|
1254
|
-
offset = origin - pos;
|
|
1255
|
-
}
|
|
1256
|
-
break;
|
|
1257
|
-
}
|
|
1258
|
-
default: {
|
|
1259
|
-
pos = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
|
|
1260
|
-
if (dir === 'left') {
|
|
1261
|
-
offset = pos - origin;
|
|
1262
|
-
}
|
|
1263
|
-
else {
|
|
1264
|
-
offset = origin - pos;
|
|
1265
|
-
}
|
|
1266
|
-
}
|
|
1267
|
-
}
|
|
1268
|
-
if (offset >= 90) {
|
|
1269
|
-
offset = 90;
|
|
1270
|
-
form.elements.gesture.style.opacity = '1';
|
|
1271
|
-
form.elements.gesture.classList.add('done');
|
|
1272
|
-
}
|
|
1273
|
-
else {
|
|
1274
|
-
form.elements.gesture.classList.remove('done');
|
|
1275
|
-
if (offset < 0) {
|
|
1276
|
-
offset = 0;
|
|
1277
|
-
form.elements.gesture.style.opacity = '0';
|
|
1278
|
-
}
|
|
1279
|
-
else {
|
|
1280
|
-
form.elements.gesture.style.opacity = '1';
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
form.elements.gesture.style.transform = 'scale(' + (offset / 90).toString() + ')';
|
|
1284
|
-
switch (dir) {
|
|
1285
|
-
case 'top':
|
|
1286
|
-
case 'bottom': {
|
|
1287
|
-
form.elements.gesture.style.left = (rect.left + ((rect.width - 20) / 2)).toString() + 'px';
|
|
1288
|
-
if (dir === 'top') {
|
|
1289
|
-
form.elements.gesture.style.top = (rect.top + (offset / 1.5)).toString() + 'px';
|
|
1290
|
-
}
|
|
1291
|
-
else {
|
|
1292
|
-
form.elements.gesture.style.top = (rect.bottom - 20 - (offset / 1.5)).toString() + 'px';
|
|
1293
|
-
}
|
|
1294
|
-
break;
|
|
1295
|
-
}
|
|
1296
|
-
default: {
|
|
1297
|
-
form.elements.gesture.style.top = (rect.top + ((rect.height - 20) / 2)).toString() + 'px';
|
|
1298
|
-
if (dir === 'left') {
|
|
1299
|
-
form.elements.gesture.style.left = (rect.left + (offset / 1.5)).toString() + 'px';
|
|
1300
|
-
}
|
|
1301
|
-
else {
|
|
1302
|
-
form.elements.gesture.style.left = (rect.right - 20 - (offset / 1.5)).toString() + 'px';
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
},
|
|
1307
|
-
end: () => {
|
|
1308
|
-
form.elements.gesture.style.opacity = '0';
|
|
1309
|
-
if (offset < 90) {
|
|
1310
|
-
return;
|
|
1311
|
-
}
|
|
1312
|
-
handler === null || handler === void 0 ? void 0 : handler(dir);
|
|
1313
|
-
}
|
|
1314
|
-
});
|
|
1315
|
-
}
|
|
1316
|
-
else {
|
|
1317
|
-
(() => __awaiter(this, void 0, void 0, function* () {
|
|
1318
|
-
const now = Date.now();
|
|
1319
|
-
if (now - gestureWheel.last > 250) {
|
|
1320
|
-
gestureWheel.offset = 0;
|
|
1321
|
-
gestureWheel.done = false;
|
|
1322
|
-
gestureWheel.timer = 0;
|
|
1323
|
-
gestureWheel.firstTimer = false;
|
|
1324
|
-
gestureWheel.dir = '';
|
|
1325
|
-
}
|
|
1326
|
-
gestureWheel.last = now;
|
|
1327
|
-
if (gestureWheel.firstTimer) {
|
|
1328
|
-
return;
|
|
1329
|
-
}
|
|
1330
|
-
if (gestureWheel.done) {
|
|
1331
|
-
return;
|
|
1332
|
-
}
|
|
1333
|
-
let deltaY = oe.deltaY;
|
|
1334
|
-
let deltaX = oe.deltaX;
|
|
1335
|
-
if (clickgo.dom.is.shift) {
|
|
1336
|
-
deltaY = oe.deltaX;
|
|
1337
|
-
deltaX = oe.deltaY;
|
|
1338
|
-
}
|
|
1339
|
-
if (gestureWheel.dir === '') {
|
|
1340
|
-
if (Math.abs(deltaY) > Math.abs(deltaX)) {
|
|
1341
|
-
if (deltaY < 0) {
|
|
1342
|
-
gestureWheel.dir = 'top';
|
|
1343
|
-
}
|
|
1344
|
-
else {
|
|
1345
|
-
gestureWheel.dir = 'bottom';
|
|
1346
|
-
}
|
|
1347
|
-
}
|
|
1348
|
-
else {
|
|
1349
|
-
if (deltaX < 0) {
|
|
1350
|
-
gestureWheel.dir = 'left';
|
|
1351
|
-
}
|
|
1352
|
-
else {
|
|
1353
|
-
gestureWheel.dir = 'right';
|
|
1354
|
-
}
|
|
1355
|
-
}
|
|
1356
|
-
const rtn = before(oe, gestureWheel.dir);
|
|
1357
|
-
if (rtn === 1) {
|
|
1358
|
-
oe.stopPropagation();
|
|
1359
|
-
oe.preventDefault();
|
|
1360
|
-
}
|
|
1361
|
-
else {
|
|
1362
|
-
if (rtn === -1) {
|
|
1363
|
-
oe.stopPropagation();
|
|
1364
|
-
gestureWheel.done = true;
|
|
1365
|
-
}
|
|
1366
|
-
else {
|
|
1367
|
-
gestureWheel.dir = '';
|
|
1368
|
-
}
|
|
1369
|
-
return;
|
|
1370
|
-
}
|
|
1371
|
-
form.elements.gesture.style.transform = 'scale(0)';
|
|
1372
|
-
switch (gestureWheel.dir) {
|
|
1373
|
-
case 'top':
|
|
1374
|
-
case 'bottom': {
|
|
1375
|
-
form.elements.gesture.style.left = (rect.left + ((rect.width - 20) / 2)).toString() + 'px';
|
|
1376
|
-
if (gestureWheel.dir === 'top') {
|
|
1377
|
-
form.elements.gesture.style.top = (rect.top + 10).toString() + 'px';
|
|
1378
|
-
}
|
|
1379
|
-
else {
|
|
1380
|
-
form.elements.gesture.style.top = (rect.bottom - 10).toString() + 'px';
|
|
1381
|
-
}
|
|
1382
|
-
break;
|
|
1383
|
-
}
|
|
1384
|
-
default: {
|
|
1385
|
-
form.elements.gesture.style.top = (rect.top + ((rect.height - 20) / 2)).toString() + 'px';
|
|
1386
|
-
if (gestureWheel.dir === 'left') {
|
|
1387
|
-
form.elements.gesture.style.left = (rect.left + 10).toString() + 'px';
|
|
1388
|
-
}
|
|
1389
|
-
else {
|
|
1390
|
-
form.elements.gesture.style.left = (rect.right - 10).toString() + 'px';
|
|
1391
|
-
}
|
|
1392
|
-
}
|
|
1393
|
-
}
|
|
1394
|
-
gestureWheel.firstTimer = true;
|
|
1395
|
-
yield tool.sleep(30);
|
|
1396
|
-
gestureWheel.firstTimer = false;
|
|
1397
|
-
form.elements.gesture.classList.add('ani');
|
|
1398
|
-
}
|
|
1399
|
-
switch (gestureWheel.dir) {
|
|
1400
|
-
case 'top':
|
|
1401
|
-
case 'bottom': {
|
|
1402
|
-
gestureWheel.offset += (gestureWheel.dir === 'top') ? -deltaY : deltaY;
|
|
1403
|
-
break;
|
|
1404
|
-
}
|
|
1405
|
-
default: {
|
|
1406
|
-
gestureWheel.offset += (gestureWheel.dir === 'left') ? -deltaX : deltaX;
|
|
1407
|
-
}
|
|
1408
|
-
}
|
|
1409
|
-
if (gestureWheel.offset < 0) {
|
|
1410
|
-
gestureWheel.offset = 0;
|
|
1411
|
-
form.elements.gesture.style.opacity = '0';
|
|
1412
|
-
return;
|
|
1413
|
-
}
|
|
1414
|
-
form.elements.gesture.style.opacity = '1';
|
|
1415
|
-
let offset = gestureWheel.offset / 1.38;
|
|
1416
|
-
if (offset > 90) {
|
|
1417
|
-
offset = 90;
|
|
1418
|
-
form.elements.gesture.classList.add('done');
|
|
1419
|
-
}
|
|
1420
|
-
else {
|
|
1421
|
-
form.elements.gesture.classList.remove('done');
|
|
1422
|
-
}
|
|
1423
|
-
form.elements.gesture.style.transform = 'scale(' + (offset / 90).toString() + ')';
|
|
1424
|
-
switch (gestureWheel.dir) {
|
|
1425
|
-
case 'top': {
|
|
1426
|
-
form.elements.gesture.style.top = (rect.top + (offset / 1.5)).toString() + 'px';
|
|
1427
|
-
break;
|
|
1428
|
-
}
|
|
1429
|
-
case 'bottom': {
|
|
1430
|
-
form.elements.gesture.style.top = (rect.bottom - 20 - (offset / 1.5)).toString() + 'px';
|
|
1431
|
-
break;
|
|
1432
|
-
}
|
|
1433
|
-
case 'left': {
|
|
1434
|
-
form.elements.gesture.style.left = (rect.left + (offset / 1.5)).toString() + 'px';
|
|
1435
|
-
break;
|
|
1436
|
-
}
|
|
1437
|
-
default: {
|
|
1438
|
-
form.elements.gesture.style.left = (rect.right - 20 - (offset / 1.5)).toString() + 'px';
|
|
1439
|
-
}
|
|
1440
|
-
}
|
|
1441
|
-
clearTimeout(gestureWheel.timer);
|
|
1442
|
-
if (offset < 90) {
|
|
1443
|
-
gestureWheel.timer = window.setTimeout(() => {
|
|
1444
|
-
form.elements.gesture.style.opacity = '0';
|
|
1445
|
-
form.elements.gesture.classList.remove('ani');
|
|
1446
|
-
}, 250);
|
|
1447
|
-
return;
|
|
1448
|
-
}
|
|
1449
|
-
gestureWheel.done = true;
|
|
1450
|
-
handler === null || handler === void 0 ? void 0 : handler(gestureWheel.dir);
|
|
1451
|
-
yield tool.sleep(500);
|
|
1452
|
-
form.elements.gesture.style.opacity = '0';
|
|
1453
|
-
form.elements.gesture.classList.remove('ani');
|
|
1454
|
-
}))().catch((e) => {
|
|
1455
|
-
console.log('error', 'dom.bindGesture', e);
|
|
1456
|
-
});
|
|
1457
|
-
}
|
|
1458
|
-
}
|
|
1459
|
-
let lastLongTime = 0;
|
|
1460
|
-
function allowEvent(e) {
|
|
1461
|
-
const now = Date.now();
|
|
1462
|
-
if (now - lastLongTime < 5) {
|
|
1463
|
-
return false;
|
|
1464
|
-
}
|
|
1465
|
-
const current = e.currentTarget;
|
|
1466
|
-
if (current.dataset.cgDisabled !== undefined) {
|
|
1467
|
-
return false;
|
|
1468
|
-
}
|
|
1469
|
-
if (findParentByData(current, 'cg-disabled')) {
|
|
1470
|
-
return false;
|
|
1471
|
-
}
|
|
1472
|
-
return true;
|
|
1473
|
-
}
|
|
1474
|
-
function bindLong(e, long) {
|
|
1475
|
-
if (hasTouchButMouse(e)) {
|
|
1476
|
-
return;
|
|
1477
|
-
}
|
|
1478
|
-
const tx = (e instanceof MouseEvent || e.type === 'mousedown') ? e.clientX : e.touches[0].clientX;
|
|
1479
|
-
const ty = (e instanceof MouseEvent || e.type === 'mousedown') ? e.clientY : e.touches[0].clientY;
|
|
1480
|
-
let ox = 0;
|
|
1481
|
-
let oy = 0;
|
|
1482
|
-
let isLong = false;
|
|
1483
|
-
let timer = window.setTimeout(() => {
|
|
1484
|
-
clearTimeout(timer);
|
|
1485
|
-
timer = undefined;
|
|
1486
|
-
if (ox <= 1 && oy <= 1) {
|
|
1487
|
-
isLong = true;
|
|
1488
|
-
const rtn = long(e);
|
|
1489
|
-
if (rtn instanceof Promise) {
|
|
1490
|
-
rtn.catch((e) => {
|
|
1491
|
-
throw e;
|
|
1492
|
-
});
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
}, 300);
|
|
1496
|
-
bindDown(e, {
|
|
1497
|
-
move: (e) => {
|
|
1498
|
-
const x = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
|
|
1499
|
-
const y = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
|
|
1500
|
-
ox = Math.abs(x - tx);
|
|
1501
|
-
oy = Math.abs(y - ty);
|
|
1502
|
-
},
|
|
1503
|
-
up: () => {
|
|
1504
|
-
if (timer !== undefined) {
|
|
1505
|
-
clearTimeout(timer);
|
|
1506
|
-
timer = undefined;
|
|
1507
|
-
}
|
|
1508
|
-
else if (isLong) {
|
|
1509
|
-
lastLongTime = Date.now();
|
|
1510
|
-
}
|
|
1511
|
-
}
|
|
1512
|
-
});
|
|
1513
|
-
}
|
|
1514
|
-
let bindDragData = undefined;
|
|
1515
|
-
function setDragData(data) {
|
|
1516
|
-
bindDragData = data;
|
|
1517
|
-
}
|
|
1518
|
-
function bindDrag(e, opt) {
|
|
1519
|
-
bindDragData = opt.data;
|
|
1520
|
-
let otop = 0;
|
|
1521
|
-
let oleft = 0;
|
|
1522
|
-
let nel = null;
|
|
1523
|
-
bindMove(e, {
|
|
1524
|
-
'object': opt.el,
|
|
1525
|
-
'start': function (x, y) {
|
|
1526
|
-
var _a;
|
|
1527
|
-
const rect = opt.el.getBoundingClientRect();
|
|
1528
|
-
form.showDrag();
|
|
1529
|
-
form.moveDrag({
|
|
1530
|
-
'top': rect.top,
|
|
1531
|
-
'left': rect.left,
|
|
1532
|
-
'width': rect.width,
|
|
1533
|
-
'height': rect.height,
|
|
1534
|
-
'icon': true
|
|
1535
|
-
});
|
|
1536
|
-
otop = rect.top;
|
|
1537
|
-
oleft = rect.left;
|
|
1538
|
-
(_a = opt.start) === null || _a === void 0 ? void 0 : _a.call(opt, x, y);
|
|
1539
|
-
},
|
|
1540
|
-
'move': function (e, o) {
|
|
1541
|
-
var _a;
|
|
1542
|
-
const ntop = otop + o.oy;
|
|
1543
|
-
const nleft = oleft + o.ox;
|
|
1544
|
-
form.moveDrag({
|
|
1545
|
-
'top': ntop,
|
|
1546
|
-
'left': nleft,
|
|
1547
|
-
'icon': false
|
|
1548
|
-
});
|
|
1549
|
-
otop = ntop;
|
|
1550
|
-
oleft = nleft;
|
|
1551
|
-
const els = document.elementsFromPoint(o.x, o.y);
|
|
1552
|
-
for (const el of els) {
|
|
1553
|
-
if (el.dataset.cgDrop === undefined) {
|
|
1554
|
-
continue;
|
|
1555
|
-
}
|
|
1556
|
-
if (el === opt.el) {
|
|
1557
|
-
continue;
|
|
1558
|
-
}
|
|
1559
|
-
if (el === nel) {
|
|
1560
|
-
return;
|
|
1561
|
-
}
|
|
1562
|
-
if (nel !== null) {
|
|
1563
|
-
nel.removeAttribute('data-cg-hover');
|
|
1564
|
-
nel.dispatchEvent(new CustomEvent('dragleave', {
|
|
1565
|
-
'detail': {
|
|
1566
|
-
'value': bindDragData
|
|
1567
|
-
}
|
|
1568
|
-
}));
|
|
1569
|
-
}
|
|
1570
|
-
el.dataset.cgHover = '';
|
|
1571
|
-
nel = el;
|
|
1572
|
-
nel.dispatchEvent(new CustomEvent('dragenter', {
|
|
1573
|
-
'detail': {
|
|
1574
|
-
'value': bindDragData
|
|
1575
|
-
}
|
|
1576
|
-
}));
|
|
1577
|
-
return;
|
|
1578
|
-
}
|
|
1579
|
-
form.moveDrag({
|
|
1580
|
-
'icon': true
|
|
1581
|
-
});
|
|
1582
|
-
if (nel === null) {
|
|
1583
|
-
return;
|
|
1584
|
-
}
|
|
1585
|
-
nel.removeAttribute('data-cg-hover');
|
|
1586
|
-
nel.dispatchEvent(new CustomEvent('dragleave', {
|
|
1587
|
-
'detail': {
|
|
1588
|
-
'value': bindDragData
|
|
1589
|
-
}
|
|
1590
|
-
}));
|
|
1591
|
-
nel = null;
|
|
1592
|
-
(_a = opt.move) === null || _a === void 0 ? void 0 : _a.call(opt, e, o);
|
|
1593
|
-
},
|
|
1594
|
-
'end': function (moveTimes, e) {
|
|
1595
|
-
var _a;
|
|
1596
|
-
form.hideDrag();
|
|
1597
|
-
if (nel === null) {
|
|
1598
|
-
return;
|
|
1599
|
-
}
|
|
1600
|
-
nel.removeAttribute('data-cg-hover');
|
|
1601
|
-
nel.dispatchEvent(new CustomEvent('drop', {
|
|
1602
|
-
'detail': {
|
|
1603
|
-
'value': bindDragData
|
|
1604
|
-
}
|
|
1605
|
-
}));
|
|
1606
|
-
(_a = opt.end) === null || _a === void 0 ? void 0 : _a.call(opt, moveTimes, e);
|
|
1607
|
-
bindDragData = undefined;
|
|
1608
|
-
}
|
|
1609
|
-
});
|
|
1610
|
-
}
|
|
1611
|
-
exports.is = clickgo.vue.reactive({
|
|
1612
|
-
'move': false,
|
|
1613
|
-
'shift': false,
|
|
1614
|
-
'ctrl': false,
|
|
1615
|
-
'meta': false,
|
|
1616
|
-
'full': false,
|
|
1617
|
-
'dark': window.matchMedia('(prefers-color-scheme: dark)').matches,
|
|
1618
|
-
});
|
|
1619
|
-
window.addEventListener('keydown', function (e) {
|
|
1620
|
-
switch (e.key) {
|
|
1621
|
-
case 'Shift': {
|
|
1622
|
-
exports.is.shift = true;
|
|
1623
|
-
break;
|
|
1624
|
-
}
|
|
1625
|
-
case 'Control': {
|
|
1626
|
-
exports.is.ctrl = true;
|
|
1627
|
-
break;
|
|
1628
|
-
}
|
|
1629
|
-
case 'Meta': {
|
|
1630
|
-
exports.is.meta = true;
|
|
1631
|
-
break;
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
core.trigger('keydown', e);
|
|
1635
|
-
});
|
|
1636
|
-
window.addEventListener('keyup', function (e) {
|
|
1637
|
-
switch (e.key) {
|
|
1638
|
-
case 'Shift': {
|
|
1639
|
-
exports.is.shift = false;
|
|
1640
|
-
break;
|
|
1641
|
-
}
|
|
1642
|
-
case 'Control': {
|
|
1643
|
-
exports.is.ctrl = false;
|
|
1644
|
-
break;
|
|
1645
|
-
}
|
|
1646
|
-
case 'Meta': {
|
|
1647
|
-
exports.is.meta = false;
|
|
1648
|
-
break;
|
|
1649
|
-
}
|
|
1650
|
-
}
|
|
1651
|
-
core.trigger('keyup', e);
|
|
1652
|
-
});
|
|
1653
|
-
function bindMove(e, opt) {
|
|
1654
|
-
var _a, _b, _c, _d, _e;
|
|
1655
|
-
if (hasTouchButMouse(e)) {
|
|
1656
|
-
return {
|
|
1657
|
-
'left': 0,
|
|
1658
|
-
'top': 0,
|
|
1659
|
-
'right': 0,
|
|
1660
|
-
'bottom': 0
|
|
1661
|
-
};
|
|
1662
|
-
}
|
|
1663
|
-
exports.is.move = true;
|
|
1664
|
-
setGlobalCursor((_a = opt.cursor) !== null && _a !== void 0 ? _a : getComputedStyle(e.target).cursor);
|
|
1665
|
-
let tx = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
|
|
1666
|
-
let ty = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
|
|
1667
|
-
let left, top, right, bottom;
|
|
1668
|
-
if (opt.areaObject) {
|
|
1669
|
-
if (!(opt.areaObject instanceof Element)) {
|
|
1670
|
-
opt.areaObject = opt.areaObject.$el;
|
|
1671
|
-
}
|
|
1672
|
-
const areaRect = opt.areaObject.getBoundingClientRect();
|
|
1673
|
-
const areaStyle = getComputedStyle(opt.areaObject);
|
|
1674
|
-
left = areaRect.left + parseFloat(areaStyle.borderLeftWidth) + parseFloat(areaStyle.paddingLeft);
|
|
1675
|
-
top = areaRect.top + parseFloat(areaStyle.borderTopWidth) + parseFloat(areaStyle.paddingTop);
|
|
1676
|
-
right = areaRect.left + areaRect.width - (parseFloat(areaStyle.borderRightWidth)
|
|
1677
|
-
+ parseFloat(areaStyle.paddingRight));
|
|
1678
|
-
bottom = areaRect.top + areaRect.height - (parseFloat(areaStyle.borderRightWidth)
|
|
1679
|
-
+ parseFloat(areaStyle.paddingRight));
|
|
1680
|
-
}
|
|
1681
|
-
else {
|
|
1682
|
-
const area = core.getAvailArea();
|
|
1683
|
-
left = (_b = opt.left) !== null && _b !== void 0 ? _b : area.left;
|
|
1684
|
-
top = (_c = opt.top) !== null && _c !== void 0 ? _c : area.top;
|
|
1685
|
-
right = (_d = opt.right) !== null && _d !== void 0 ? _d : area.width;
|
|
1686
|
-
bottom = (_e = opt.bottom) !== null && _e !== void 0 ? _e : area.height;
|
|
1687
|
-
}
|
|
1688
|
-
if (opt.offsetLeft) {
|
|
1689
|
-
left += opt.offsetLeft;
|
|
1690
|
-
}
|
|
1691
|
-
if (opt.offsetTop) {
|
|
1692
|
-
top += opt.offsetTop;
|
|
1693
|
-
}
|
|
1694
|
-
if (opt.offsetRight) {
|
|
1695
|
-
right += opt.offsetRight;
|
|
1696
|
-
}
|
|
1697
|
-
if (opt.offsetBottom) {
|
|
1698
|
-
bottom += opt.offsetBottom;
|
|
1699
|
-
}
|
|
1700
|
-
let isBorder = false;
|
|
1701
|
-
let objectLeft, objectTop, objectWidth, objectHeight;
|
|
1702
|
-
let offsetLeft = 0, offsetTop = 0, offsetRight = 0, offsetBottom = 0;
|
|
1703
|
-
const moveTimes = [];
|
|
1704
|
-
bindDown(e, {
|
|
1705
|
-
start: () => {
|
|
1706
|
-
var _a, _b, _c, _d;
|
|
1707
|
-
if (opt.start) {
|
|
1708
|
-
if (opt.start(tx, ty) === false) {
|
|
1709
|
-
setGlobalCursor();
|
|
1710
|
-
return false;
|
|
1711
|
-
}
|
|
1712
|
-
}
|
|
1713
|
-
if (opt.object) {
|
|
1714
|
-
if (!(opt.object instanceof Element)) {
|
|
1715
|
-
opt.object = opt.object.$el;
|
|
1716
|
-
}
|
|
1717
|
-
const rect = opt.object.getBoundingClientRect();
|
|
1718
|
-
objectLeft = rect.left;
|
|
1719
|
-
objectTop = rect.top;
|
|
1720
|
-
objectWidth = rect.width;
|
|
1721
|
-
objectHeight = rect.height;
|
|
1722
|
-
}
|
|
1723
|
-
else {
|
|
1724
|
-
objectLeft = (_a = opt.objectLeft) !== null && _a !== void 0 ? _a : 0;
|
|
1725
|
-
objectTop = (_b = opt.objectTop) !== null && _b !== void 0 ? _b : 0;
|
|
1726
|
-
objectWidth = (_c = opt.objectWidth) !== null && _c !== void 0 ? _c : 0;
|
|
1727
|
-
objectHeight = (_d = opt.objectHeight) !== null && _d !== void 0 ? _d : 0;
|
|
1728
|
-
}
|
|
1729
|
-
if (objectWidth > 0) {
|
|
1730
|
-
offsetLeft = tx - objectLeft;
|
|
1731
|
-
}
|
|
1732
|
-
if (objectHeight > 0) {
|
|
1733
|
-
offsetTop = ty - objectTop;
|
|
1734
|
-
}
|
|
1735
|
-
offsetRight = objectWidth - offsetLeft;
|
|
1736
|
-
offsetBottom = objectHeight - offsetTop;
|
|
1737
|
-
},
|
|
1738
|
-
move: (e, dir) => {
|
|
1739
|
-
var _a, _b, _c;
|
|
1740
|
-
let x, y;
|
|
1741
|
-
x = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
|
|
1742
|
-
y = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
|
|
1743
|
-
if (x === tx && y === ty) {
|
|
1744
|
-
return;
|
|
1745
|
-
}
|
|
1746
|
-
let inBorderTop = false, inBorderRight = false, inBorderBottom = false, inBorderLeft = false;
|
|
1747
|
-
const nowLeft = x - offsetLeft;
|
|
1748
|
-
const nowRight = x + offsetRight;
|
|
1749
|
-
if (nowLeft <= left) {
|
|
1750
|
-
inBorderLeft = true;
|
|
1751
|
-
if (nowLeft < left && x < tx) {
|
|
1752
|
-
if (tx - offsetLeft > left) {
|
|
1753
|
-
x = left + offsetLeft;
|
|
1754
|
-
}
|
|
1755
|
-
else {
|
|
1756
|
-
x = tx;
|
|
1757
|
-
}
|
|
1758
|
-
}
|
|
1759
|
-
}
|
|
1760
|
-
else if (offsetRight !== 0) {
|
|
1761
|
-
if (nowRight >= right) {
|
|
1762
|
-
inBorderRight = true;
|
|
1763
|
-
if (nowRight > right && x > tx) {
|
|
1764
|
-
if (tx + offsetRight < right) {
|
|
1765
|
-
x = right - offsetRight;
|
|
1766
|
-
}
|
|
1767
|
-
else {
|
|
1768
|
-
x = tx;
|
|
1769
|
-
}
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
}
|
|
1773
|
-
else if (offsetRight === 0) {
|
|
1774
|
-
const r1 = right - 1;
|
|
1775
|
-
if (x >= r1) {
|
|
1776
|
-
inBorderRight = true;
|
|
1777
|
-
if (x > r1 && x > tx) {
|
|
1778
|
-
if (tx < r1) {
|
|
1779
|
-
x = r1;
|
|
1780
|
-
}
|
|
1781
|
-
else {
|
|
1782
|
-
x = tx;
|
|
1783
|
-
}
|
|
1784
|
-
}
|
|
1785
|
-
}
|
|
1786
|
-
}
|
|
1787
|
-
const nowTop = y - offsetTop;
|
|
1788
|
-
const nowBottom = y + offsetBottom;
|
|
1789
|
-
if (nowTop <= top) {
|
|
1790
|
-
inBorderTop = true;
|
|
1791
|
-
if (nowTop < top && y < ty) {
|
|
1792
|
-
if (ty - offsetTop > top) {
|
|
1793
|
-
y = top + offsetTop;
|
|
1794
|
-
}
|
|
1795
|
-
else {
|
|
1796
|
-
y = ty;
|
|
1797
|
-
}
|
|
1798
|
-
}
|
|
1799
|
-
}
|
|
1800
|
-
else if (offsetBottom !== 0) {
|
|
1801
|
-
if (nowBottom >= bottom) {
|
|
1802
|
-
inBorderBottom = true;
|
|
1803
|
-
if (nowBottom > bottom && y > ty) {
|
|
1804
|
-
if (ty + offsetBottom < bottom) {
|
|
1805
|
-
y = bottom - offsetBottom;
|
|
1806
|
-
}
|
|
1807
|
-
else {
|
|
1808
|
-
y = ty;
|
|
1809
|
-
}
|
|
1810
|
-
}
|
|
1811
|
-
}
|
|
1812
|
-
}
|
|
1813
|
-
else if (offsetBottom === 0) {
|
|
1814
|
-
const b1 = bottom - 1;
|
|
1815
|
-
if (y >= b1) {
|
|
1816
|
-
inBorderBottom = true;
|
|
1817
|
-
if (y > b1 && y > ty) {
|
|
1818
|
-
if (ty < b1) {
|
|
1819
|
-
y = b1;
|
|
1820
|
-
}
|
|
1821
|
-
else {
|
|
1822
|
-
y = ty;
|
|
1823
|
-
}
|
|
1824
|
-
}
|
|
1825
|
-
}
|
|
1826
|
-
}
|
|
1827
|
-
let border = '';
|
|
1828
|
-
if (inBorderTop || inBorderRight || inBorderBottom || inBorderLeft) {
|
|
1829
|
-
if (inBorderTop) {
|
|
1830
|
-
if (x - left <= 20) {
|
|
1831
|
-
border = 'lt';
|
|
1832
|
-
}
|
|
1833
|
-
else if (right - x <= 20) {
|
|
1834
|
-
border = 'tr';
|
|
1835
|
-
}
|
|
1836
|
-
else {
|
|
1837
|
-
border = 't';
|
|
1838
|
-
}
|
|
1839
|
-
}
|
|
1840
|
-
else if (inBorderRight) {
|
|
1841
|
-
if (y - top <= 20) {
|
|
1842
|
-
border = 'tr';
|
|
1843
|
-
}
|
|
1844
|
-
else if (bottom - y <= 20) {
|
|
1845
|
-
border = 'rb';
|
|
1846
|
-
}
|
|
1847
|
-
else {
|
|
1848
|
-
border = 'r';
|
|
1849
|
-
}
|
|
1850
|
-
}
|
|
1851
|
-
else if (inBorderBottom) {
|
|
1852
|
-
if (right - x <= 20) {
|
|
1853
|
-
border = 'rb';
|
|
1854
|
-
}
|
|
1855
|
-
else if (x - left <= 20) {
|
|
1856
|
-
border = 'bl';
|
|
1857
|
-
}
|
|
1858
|
-
else {
|
|
1859
|
-
border = 'b';
|
|
1860
|
-
}
|
|
1861
|
-
}
|
|
1862
|
-
else if (inBorderLeft) {
|
|
1863
|
-
if (y - top <= 20) {
|
|
1864
|
-
border = 'lt';
|
|
1865
|
-
}
|
|
1866
|
-
else if (bottom - y <= 20) {
|
|
1867
|
-
border = 'bl';
|
|
1868
|
-
}
|
|
1869
|
-
else {
|
|
1870
|
-
border = 'l';
|
|
1871
|
-
}
|
|
1872
|
-
}
|
|
1873
|
-
if (!isBorder) {
|
|
1874
|
-
isBorder = true;
|
|
1875
|
-
(_a = opt.borderIn) === null || _a === void 0 ? void 0 : _a.call(opt, x, y, border, e);
|
|
1876
|
-
}
|
|
1877
|
-
}
|
|
1878
|
-
else {
|
|
1879
|
-
if (isBorder) {
|
|
1880
|
-
isBorder = false;
|
|
1881
|
-
(_b = opt.borderOut) === null || _b === void 0 ? void 0 : _b.call(opt);
|
|
1882
|
-
}
|
|
1883
|
-
}
|
|
1884
|
-
const ox = x - tx;
|
|
1885
|
-
const oy = y - ty;
|
|
1886
|
-
moveTimes.push({
|
|
1887
|
-
'time': Date.now(),
|
|
1888
|
-
'ox': ox,
|
|
1889
|
-
'oy': oy
|
|
1890
|
-
});
|
|
1891
|
-
(_c = opt.move) === null || _c === void 0 ? void 0 : _c.call(opt, e, {
|
|
1892
|
-
'ox': ox,
|
|
1893
|
-
'oy': oy,
|
|
1894
|
-
'x': x,
|
|
1895
|
-
'y': y,
|
|
1896
|
-
'border': border,
|
|
1897
|
-
'inBorder': {
|
|
1898
|
-
'top': inBorderTop,
|
|
1899
|
-
'right': inBorderRight,
|
|
1900
|
-
'bottom': inBorderBottom,
|
|
1901
|
-
'left': inBorderLeft
|
|
1902
|
-
},
|
|
1903
|
-
'dir': dir
|
|
1904
|
-
});
|
|
1905
|
-
tx = x;
|
|
1906
|
-
ty = y;
|
|
1907
|
-
},
|
|
1908
|
-
up: (e) => {
|
|
1909
|
-
var _a;
|
|
1910
|
-
exports.is.move = false;
|
|
1911
|
-
setGlobalCursor();
|
|
1912
|
-
(_a = opt.up) === null || _a === void 0 ? void 0 : _a.call(opt, moveTimes, e);
|
|
1913
|
-
},
|
|
1914
|
-
end: (e) => {
|
|
1915
|
-
var _a;
|
|
1916
|
-
(_a = opt.end) === null || _a === void 0 ? void 0 : _a.call(opt, moveTimes, e);
|
|
1917
|
-
}
|
|
1918
|
-
});
|
|
1919
|
-
if (opt.showRect) {
|
|
1920
|
-
form.showRectangle(tx, ty, {
|
|
1921
|
-
'left': left,
|
|
1922
|
-
'top': top,
|
|
1923
|
-
'width': right - left,
|
|
1924
|
-
'height': bottom - top
|
|
1925
|
-
});
|
|
1926
|
-
setTimeout(() => {
|
|
1927
|
-
form.hideRectangle();
|
|
1928
|
-
}, 3000);
|
|
1929
|
-
}
|
|
1930
|
-
return {
|
|
1931
|
-
'left': left,
|
|
1932
|
-
'top': top,
|
|
1933
|
-
'right': right,
|
|
1934
|
-
'bottom': bottom
|
|
1935
|
-
};
|
|
1936
|
-
}
|
|
1937
|
-
function bindResize(e, opt) {
|
|
1938
|
-
var _a, _b;
|
|
1939
|
-
if (hasTouchButMouse(e)) {
|
|
1940
|
-
return;
|
|
1941
|
-
}
|
|
1942
|
-
opt.minWidth = (_a = opt.minWidth) !== null && _a !== void 0 ? _a : 0;
|
|
1943
|
-
opt.minHeight = (_b = opt.minHeight) !== null && _b !== void 0 ? _b : 0;
|
|
1944
|
-
const x = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
|
|
1945
|
-
const y = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
|
|
1946
|
-
let offsetLeft, offsetTop, offsetRight, offsetBottom;
|
|
1947
|
-
let left, top, right, bottom;
|
|
1948
|
-
if (opt.objectLeft === undefined
|
|
1949
|
-
|| opt.objectTop === undefined
|
|
1950
|
-
|| opt.objectWidth === undefined
|
|
1951
|
-
|| opt.objectHeight === undefined) {
|
|
1952
|
-
if (!opt.object) {
|
|
1953
|
-
return;
|
|
1954
|
-
}
|
|
1955
|
-
if (!(opt.object instanceof Element)) {
|
|
1956
|
-
opt.object = opt.object.$el;
|
|
1957
|
-
}
|
|
1958
|
-
const objectRect = opt.object.getBoundingClientRect();
|
|
1959
|
-
opt.objectLeft = objectRect.left;
|
|
1960
|
-
opt.objectTop = objectRect.top;
|
|
1961
|
-
opt.objectWidth = objectRect.width;
|
|
1962
|
-
opt.objectHeight = objectRect.height;
|
|
1963
|
-
}
|
|
1964
|
-
if (opt.border === 'tr' || opt.border === 'r' || opt.border === 'rb') {
|
|
1965
|
-
left = opt.objectLeft + opt.minWidth;
|
|
1966
|
-
offsetLeft = x - (opt.objectLeft + opt.objectWidth);
|
|
1967
|
-
offsetRight = offsetLeft;
|
|
1968
|
-
if (opt.maxWidth) {
|
|
1969
|
-
right = opt.objectLeft + opt.maxWidth;
|
|
1970
|
-
}
|
|
1971
|
-
}
|
|
1972
|
-
else if (opt.border === 'bl' || opt.border === 'l' || opt.border === 'lt') {
|
|
1973
|
-
right = opt.objectLeft + opt.objectWidth - opt.minWidth;
|
|
1974
|
-
offsetLeft = x - opt.objectLeft;
|
|
1975
|
-
offsetRight = offsetLeft;
|
|
1976
|
-
if (opt.maxWidth) {
|
|
1977
|
-
left = opt.objectLeft + opt.objectWidth - opt.maxWidth;
|
|
1978
|
-
}
|
|
1979
|
-
}
|
|
1980
|
-
if (opt.border === 'rb' || opt.border === 'b' || opt.border === 'bl') {
|
|
1981
|
-
top = opt.objectTop + opt.minHeight;
|
|
1982
|
-
offsetTop = y - (opt.objectTop + opt.objectHeight);
|
|
1983
|
-
offsetBottom = offsetTop;
|
|
1984
|
-
if (opt.maxHeight) {
|
|
1985
|
-
bottom = opt.objectTop + opt.maxHeight;
|
|
1986
|
-
}
|
|
1987
|
-
}
|
|
1988
|
-
else if (opt.border === 'lt' || opt.border === 't' || opt.border === 'tr') {
|
|
1989
|
-
bottom = opt.objectTop + opt.objectHeight - opt.minHeight;
|
|
1990
|
-
offsetTop = y - opt.objectTop;
|
|
1991
|
-
offsetBottom = offsetTop;
|
|
1992
|
-
if (opt.maxHeight) {
|
|
1993
|
-
top = opt.objectTop + opt.objectHeight - opt.maxHeight;
|
|
1994
|
-
}
|
|
1995
|
-
}
|
|
1996
|
-
bindMove(e, {
|
|
1997
|
-
'left': left,
|
|
1998
|
-
'top': top,
|
|
1999
|
-
'right': right,
|
|
2000
|
-
'bottom': bottom,
|
|
2001
|
-
'offsetLeft': offsetLeft,
|
|
2002
|
-
'offsetTop': offsetTop,
|
|
2003
|
-
'offsetRight': offsetRight,
|
|
2004
|
-
'offsetBottom': offsetBottom,
|
|
2005
|
-
'start': opt.start,
|
|
2006
|
-
'move': function (e, o) {
|
|
2007
|
-
var _a;
|
|
2008
|
-
if (opt.border === 'tr' || opt.border === 'r' || opt.border === 'rb') {
|
|
2009
|
-
opt.objectWidth += o.ox;
|
|
2010
|
-
}
|
|
2011
|
-
else if (opt.border === 'bl' || opt.border === 'l' || opt.border === 'lt') {
|
|
2012
|
-
opt.objectWidth -= o.ox;
|
|
2013
|
-
opt.objectLeft += o.ox;
|
|
2014
|
-
}
|
|
2015
|
-
if (opt.border === 'rb' || opt.border === 'b' || opt.border === 'bl') {
|
|
2016
|
-
opt.objectHeight += o.oy;
|
|
2017
|
-
}
|
|
2018
|
-
else if (opt.border === 'lt' || opt.border === 't' || opt.border === 'tr') {
|
|
2019
|
-
opt.objectHeight -= o.oy;
|
|
2020
|
-
opt.objectTop += o.oy;
|
|
2021
|
-
}
|
|
2022
|
-
(_a = opt.move) === null || _a === void 0 ? void 0 : _a.call(opt, opt.objectLeft, opt.objectTop, opt.objectWidth, opt.objectHeight, x, y, o.border);
|
|
2023
|
-
},
|
|
2024
|
-
'end': opt.end
|
|
2025
|
-
});
|
|
2026
|
-
}
|
|
2027
|
-
function findParentByData(el, name, value) {
|
|
2028
|
-
let parent = el.parentNode;
|
|
2029
|
-
while (parent) {
|
|
2030
|
-
if (!parent.tagName) {
|
|
2031
|
-
continue;
|
|
2032
|
-
}
|
|
2033
|
-
if (parent.tagName.toLowerCase() === 'body') {
|
|
2034
|
-
break;
|
|
2035
|
-
}
|
|
2036
|
-
const v = parent.getAttribute('data-' + name);
|
|
2037
|
-
if (v !== null) {
|
|
2038
|
-
if (value) {
|
|
2039
|
-
if (value === v) {
|
|
2040
|
-
return parent;
|
|
2041
|
-
}
|
|
2042
|
-
continue;
|
|
2043
|
-
}
|
|
2044
|
-
return parent;
|
|
2045
|
-
}
|
|
2046
|
-
parent = parent.parentNode;
|
|
2047
|
-
}
|
|
2048
|
-
return null;
|
|
2049
|
-
}
|
|
2050
|
-
function findParentByClass(el, name) {
|
|
2051
|
-
let parent = el.parentNode;
|
|
2052
|
-
while (parent) {
|
|
2053
|
-
if (!parent.tagName) {
|
|
2054
|
-
continue;
|
|
2055
|
-
}
|
|
2056
|
-
if (parent.tagName.toLowerCase() === 'body') {
|
|
2057
|
-
break;
|
|
2058
|
-
}
|
|
2059
|
-
if (parent.classList.contains(name)) {
|
|
2060
|
-
return parent;
|
|
2061
|
-
}
|
|
2062
|
-
parent = parent.parentNode;
|
|
2063
|
-
}
|
|
2064
|
-
return null;
|
|
2065
|
-
}
|
|
2066
|
-
function findParentByTag(el, name) {
|
|
2067
|
-
let parent = el.parentNode;
|
|
2068
|
-
while (parent) {
|
|
2069
|
-
if (!parent.tagName) {
|
|
2070
|
-
continue;
|
|
2071
|
-
}
|
|
2072
|
-
const tag = parent.tagName.toLowerCase();
|
|
2073
|
-
if (tag === 'body') {
|
|
2074
|
-
break;
|
|
2075
|
-
}
|
|
2076
|
-
if (tag === name) {
|
|
2077
|
-
return parent;
|
|
2078
|
-
}
|
|
2079
|
-
parent = parent.parentNode;
|
|
2080
|
-
}
|
|
2081
|
-
return null;
|
|
2082
|
-
}
|
|
2083
|
-
function index(el) {
|
|
2084
|
-
let index = 0;
|
|
2085
|
-
let p = el.previousElementSibling;
|
|
2086
|
-
while (true) {
|
|
2087
|
-
if (!p) {
|
|
2088
|
-
break;
|
|
2089
|
-
}
|
|
2090
|
-
++index;
|
|
2091
|
-
p = p.previousElementSibling;
|
|
2092
|
-
}
|
|
2093
|
-
return index;
|
|
2094
|
-
}
|
|
2095
|
-
function siblings(el) {
|
|
2096
|
-
if (!el.parentNode) {
|
|
2097
|
-
return [];
|
|
2098
|
-
}
|
|
2099
|
-
const list = [];
|
|
2100
|
-
for (let i = 0; i < el.parentNode.children.length; ++i) {
|
|
2101
|
-
const e = el.parentNode.children.item(i);
|
|
2102
|
-
if (e === el) {
|
|
2103
|
-
continue;
|
|
2104
|
-
}
|
|
2105
|
-
list.push(e);
|
|
2106
|
-
}
|
|
2107
|
-
return list;
|
|
2108
|
-
}
|
|
2109
|
-
function siblingsData(el, name) {
|
|
2110
|
-
const list = siblings(el);
|
|
2111
|
-
const olist = [];
|
|
2112
|
-
for (const item of list) {
|
|
2113
|
-
if (item.getAttribute('data-' + name) === null) {
|
|
2114
|
-
continue;
|
|
2115
|
-
}
|
|
2116
|
-
olist.push(item);
|
|
2117
|
-
}
|
|
2118
|
-
return olist;
|
|
2119
|
-
}
|
|
2120
|
-
function fullscreen() {
|
|
2121
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2122
|
-
const he = document.getElementsByTagName('html')[0];
|
|
2123
|
-
if (he.webkitRequestFullscreen) {
|
|
2124
|
-
yield he.webkitRequestFullscreen();
|
|
2125
|
-
return true;
|
|
2126
|
-
}
|
|
2127
|
-
else if (he.requestFullscreen) {
|
|
2128
|
-
yield he.requestFullscreen();
|
|
2129
|
-
return true;
|
|
2130
|
-
}
|
|
2131
|
-
else {
|
|
2132
|
-
return false;
|
|
2133
|
-
}
|
|
2134
|
-
});
|
|
2135
|
-
}
|
|
2136
|
-
function exitFullscreen() {
|
|
2137
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2138
|
-
const d = document;
|
|
2139
|
-
if (d.webkitExitFullscreen) {
|
|
2140
|
-
yield d.webkitExitFullscreen();
|
|
2141
|
-
return true;
|
|
2142
|
-
}
|
|
2143
|
-
else if (d.exitFullscreen) {
|
|
2144
|
-
yield d.exitFullscreen();
|
|
2145
|
-
return true;
|
|
2146
|
-
}
|
|
2147
|
-
else {
|
|
2148
|
-
return false;
|
|
2149
|
-
}
|
|
2150
|
-
});
|
|
2151
|
-
}
|
|
2152
|
-
function createElement(tagName) {
|
|
2153
|
-
return document.createElement(tagName);
|
|
2154
|
-
}
|
|
2155
|
-
document.addEventListener('visibilitychange', function () {
|
|
2156
|
-
if (document.hidden) {
|
|
2157
|
-
cancelAnimationFrame(watchTimer);
|
|
2158
|
-
}
|
|
2159
|
-
else {
|
|
2160
|
-
watchTimer = requestAnimationFrame(watchTimerHandler);
|
|
2161
|
-
}
|
|
2162
|
-
});
|
|
2163
|
-
document.addEventListener('fullscreenchange', function () {
|
|
2164
|
-
if (document.webkitFullscreenElement) {
|
|
2165
|
-
exports.is.full = true;
|
|
2166
|
-
return;
|
|
2167
|
-
}
|
|
2168
|
-
if (document.fullscreenElement) {
|
|
2169
|
-
exports.is.full = true;
|
|
2170
|
-
return;
|
|
2171
|
-
}
|
|
2172
|
-
exports.is.full = false;
|
|
2173
|
-
});
|
|
2174
|
-
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => {
|
|
2175
|
-
exports.is.dark = e.matches;
|
|
2176
|
-
});
|