clickgo 3.16.28 → 4.0.1

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