efront 3.26.8 → 3.26.14

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 (66) hide show
  1. package/apps/index.jsp +2 -2
  2. package/apps/pivot/dht/list.js +53 -0
  3. package/apps/pivot/index.html +3 -1
  4. package/apps/pivot/main.js +1 -0
  5. package/apps/pivot/main.less +3 -0
  6. package/apps/pivot/wow/root.js +138 -104
  7. package/apps/pivot/wow/root.less +1 -62
  8. package/coms/basic/Task.js +51 -0
  9. package/coms/basic/cross_.js +8 -0
  10. package/coms/basic/keys.js +3 -4
  11. package/coms/basic/loader.js +42 -17
  12. package/coms/basic/submit_.js +6 -3
  13. package/coms/explorer/Explorer.js +85 -0
  14. package/coms/explorer/context.js +205 -0
  15. package/coms/explorer/deepcp.js +48 -0
  16. package/{apps/pivot/wow → coms/explorer}/edit.html +1 -1
  17. package/{apps/pivot/wow → coms/explorer}/edit.js +17 -9
  18. package/coms/explorer/fileitem.html +8 -0
  19. package/coms/explorer/fileitem.js +34 -0
  20. package/coms/explorer/fileitem.less +65 -0
  21. package/coms/explorer/filetip.js +10 -0
  22. package/coms/explorer/filetip.less +5 -0
  23. package/coms/explorer/main.html +8 -0
  24. package/coms/explorer/main.js +215 -0
  25. package/coms/explorer/main.less +78 -0
  26. package/coms/frame/route.js +1 -1
  27. package/coms/shapes/file.html +9 -0
  28. package/coms/shapes/folder.html +7 -0
  29. package/coms/zimoli/Cleanup.js +9 -8
  30. package/coms/zimoli/arriswise.js +5 -4
  31. package/coms/zimoli/attr.js +2 -0
  32. package/coms/zimoli/bindGlobalkey.js +37 -0
  33. package/coms/zimoli/confirm.js +8 -8
  34. package/coms/zimoli/confirm.less +6 -80
  35. package/coms/zimoli/container.js +19 -6
  36. package/coms/zimoli/contextmenu.js +35 -15
  37. package/coms/zimoli/drag.js +7 -3
  38. package/coms/zimoli/field.html +1 -1
  39. package/coms/zimoli/field.js +8 -2
  40. package/coms/zimoli/field.less +0 -1
  41. package/coms/zimoli/getChanges.js +1 -0
  42. package/coms/zimoli/list.js +44 -33
  43. package/coms/zimoli/menu.js +1 -24
  44. package/coms/zimoli/menuItem.html +4 -1
  45. package/coms/zimoli/menuList.js +54 -104
  46. package/coms/zimoli/menuList.less +1 -0
  47. package/coms/zimoli/moveupon.js +2 -2
  48. package/coms/zimoli/overpos.js +7 -0
  49. package/coms/zimoli/popup.js +22 -27
  50. package/coms/zimoli/prompt.js +43 -5
  51. package/coms/zimoli/prompt.less +23 -0
  52. package/coms/zimoli/render.js +149 -107
  53. package/coms/zimoli/resize.js +12 -5
  54. package/coms/zimoli/rootElements.js +15 -1
  55. package/coms/zimoli/view.js +33 -0
  56. package/coms/zimoli/view.less +8 -8
  57. package/coms/zimoli/yousure.js +53 -0
  58. package/coms/zimoli/yousure.less +4 -0
  59. package/coms/zimoli/zimoli.js +10 -6
  60. package/package.json +1 -1
  61. package/public/efront.js +1 -1
  62. package/apps/pivot/wow/root.html +0 -10
  63. package/coms/zimoli/explorer.html +0 -5
  64. package/coms/zimoli/explorer.js +0 -8
  65. package/coms/zimoli/explorer.less +0 -18
  66. package/coms/zimoli/explorer_test.js +0 -4
@@ -0,0 +1,215 @@
1
+ var rect = document.createElement('rect');
2
+ rect.setAttribute('insert', '');
3
+ var touchitems = null;
4
+ var selectRected = on("resize")(rect, function () {
5
+ var lattice = this.nextElementSibling;
6
+ if (!lattice) return;
7
+ var selected = [];
8
+ if (touchitems) for (var m of touchitems) {
9
+ var file = m.$scope.d;
10
+ file.selected = overlap(m, rect);
11
+ if (file.selected) selected.push(file);
12
+ }
13
+ lattice.$scope.selected = selected;
14
+ render.refresh();
15
+ });
16
+ var dragger = null;
17
+ var touch = {
18
+ start(e) {
19
+ /**
20
+ * @type {Element}
21
+ */
22
+ var t = this;
23
+ var a = this.$scope.toActive(e);
24
+ touchitems = this.querySelectorAll("fileitem");
25
+ if (a && this.$scope.selected.indexOf(a.$scope.d) >= 0) {
26
+ dragger = e;
27
+ if (!drag.target) drag(this.$scope.selected.length === 1 ? a : this.querySelectorAll(".focused"), e);
28
+ return;
29
+ }
30
+ var pos = getScreenPosition(t.parentNode);
31
+ var pos2 = getScreenPosition(t.previousElementSibling);
32
+
33
+ rect.limit = [pos.left + t.parentNode.clientLeft, Math.max(pos.top, pos2.bottom + 1)];
34
+ rect.event = e;
35
+ rect.setAttribute('style', '');
36
+ css(rect, { left: e.clientX - pos.left - t.clientLeft, top: e.clientY - t.clientTop, width: 0, height: 0 })
37
+ },
38
+ move(e) {
39
+ if (!onclick.preventClick) return;
40
+ if (dragger) {
41
+ var tiped = null;
42
+ for (var c of touchitems) {
43
+ var d = c.$scope.d;
44
+ if (d.isfolder && !d.selected && overpos(c, e)) {
45
+ if (!c.hasAttribute('dropping')) {
46
+ if (!drag.tip) {
47
+ var t = document.createElement('dragtip');
48
+ drag.tip = t;
49
+ drag.target.appendChild(t);
50
+ drag.target.style.zIndex = zIndex(0) + 2;
51
+ css(t, {
52
+ display: "bock",
53
+ padding: "6px 10px",
54
+ height: "auto",
55
+ background: "#fff",
56
+ border: "1px solid #666",
57
+ fontSize: '14px',
58
+ lineHeight: 1,
59
+ top: '100%',
60
+ whiteSpace: 'nowrap',
61
+ position: "absolute",
62
+ });
63
+ }
64
+ css(drag.tip, 'display:block');
65
+ drag.tip.innerHTML = `<b style="color:#169;font-weight:400">移动到</b> ${c.$scope.d.name}`;
66
+ c.setAttribute('dropping', '');
67
+ }
68
+ tiped = c;
69
+ }
70
+ else {
71
+ c.removeAttribute('dropping');
72
+ }
73
+ }
74
+ if (!tiped && drag.tip) css(drag.tip, 'display:none');
75
+ return;
76
+ }
77
+ if (e.type !== 'mousemove') return;
78
+ if (!rect.parentNode) {
79
+ appendChild.insert(this.parentNode, rect, this);
80
+ resize(rect, rect.event);
81
+ }
82
+ e.moveLocked = true;
83
+ },
84
+ async end(e) {
85
+ touchitems = null;
86
+ if (dragger) {
87
+ delete drag.tip;
88
+ dragger = null;
89
+ var p = this.querySelector("[dropping]");
90
+ if (p) {
91
+ p.removeAttribute("dropping");
92
+ var $scope = this.$scope;
93
+ var base = $scope.pathlist.concat(p.$scope.d.name).join("/");
94
+ for (var s of $scope.selected) {
95
+ await $scope.mov(s, base + "/" + s.name);
96
+ }
97
+ $scope.open();
98
+ }
99
+ }
100
+ remove(rect);
101
+ },
102
+ };
103
+ var moveFocus = function (delta) {
104
+ var { selected, data } = this.$scope;
105
+ var index, targetIndex;
106
+ var boxCount = this.group;
107
+ if (delta === 'home') targetIndex = 0;
108
+ else if (delta === 'end') targetIndex = data.length - 1;
109
+ else if (delta === 'pagedown') {
110
+ if (data.length <= boxCount) {
111
+ targetIndex = data.length - 1;
112
+ }
113
+ else {
114
+ index = data.indexOf(selected[selected.length - 1]);
115
+ var e = this.getLastVisibleElement(0);
116
+ if (e) targetIndex = data.indexOf(e.$scope.d);
117
+ else targetIndex = data.length - 1;
118
+ targetIndex = (targetIndex / boxCount | 0) * boxCount + index % boxCount;
119
+ if (targetIndex >= data.length) targetIndex = data.length - 1;
120
+ }
121
+ }
122
+ else if (delta === 'pageup') {
123
+ if (data.length <= boxCount) {
124
+ targetIndex = 0;
125
+ }
126
+ else {
127
+ var f = this.getFirstVisibleElement();
128
+ var index = data.indexOf(selected[0]);
129
+ if (!f) targetIndex = 0;
130
+ else if (f.$scope.d !== selected[0]) {
131
+ targetIndex = index + ((data.indexOf(f.$scope.d) - index) / boxCount | 0) * boxCount;
132
+ }
133
+ else {
134
+ var e = this.getLastVisibleElement(0);
135
+ var fi = data.indexOf(f.$scope.d);
136
+ var ei = data.indexOf(e.$scope.d)
137
+ targetIndex = fi - ((ei - fi) / boxCount | 0) * boxCount;
138
+
139
+ }
140
+ if (targetIndex < 0) targetIndex = index % boxCount;
141
+ }
142
+
143
+ }
144
+ else if (!selected.length) {
145
+ targetIndex = /left|^up/.test(delta) ? data.length - 1 : 0;
146
+ }
147
+ else if (typeof delta === 'string') switch (delta) {
148
+ case "left":
149
+ index = data.indexOf(selected[0]);
150
+ if (selected.length > 1) { targetIndex = index; break }
151
+ targetIndex = index - 1;
152
+ if (targetIndex < 0) targetIndex = 0;
153
+ break;
154
+ case "right":
155
+ index = data.indexOf(selected[selected.length - 1]);
156
+ if (selected.length > 1) { targetIndex = index; break }
157
+ targetIndex = index + 1;
158
+ if (targetIndex >= data.length) targetIndex = data.length - 1;
159
+ break;
160
+ case "up":
161
+ index = data.indexOf(selected[0]);
162
+ if (selected.length > 1) { targetIndex = index; break }
163
+ if (data.length <= boxCount) targetIndex = 0;
164
+ else if (index >= boxCount) targetIndex = index - boxCount;
165
+ else targetIndex = index;
166
+ break;
167
+ case "down":
168
+ index = data.indexOf(selected[selected.length - 1]);
169
+ if (selected.length > 1) { targetIndex = index; break }
170
+ targetIndex = index + boxCount;
171
+ if (data.length <= boxCount) targetIndex = data.length - 1;
172
+ else {
173
+ if (targetIndex >= data.length) targetIndex = data.length - 1;
174
+ if ((targetIndex / boxCount | 0) === (index / boxCount | 0)) targetIndex = index;
175
+ }
176
+ break;
177
+
178
+ }
179
+ for (var s of selected) {
180
+ s.selected = false;
181
+ }
182
+ var d = data[targetIndex];
183
+ if (d) d.selected = true, this.$scope.selected = [d];
184
+ this.setFocus(targetIndex);
185
+ render.refresh();
186
+ };
187
+
188
+ var bindkey = function (lattice) {
189
+ for (var key of "up,down,right,left,pagedown,pageup,home,end".split(",")) {
190
+ on("keydown.only." + key)(lattice, moveFocus.bind(lattice, key));
191
+ }
192
+ };
193
+ async function ondrop(event) {
194
+ event.preventDefault();
195
+ var files = event.dataTransfer.files;
196
+ this.$scope.uploadAll(files);
197
+ }
198
+ function main() {
199
+ var page = document.createElement('explorer');
200
+ page.innerHTML = template;
201
+ moveupon(page.querySelector('lattice'), touch);
202
+ var scope = new explorer$Explorer;
203
+ renderWithDefaults(page, scope);
204
+ bind('drop')(scope.listview, ondrop);
205
+ bindkey(scope.listview);
206
+ contextmenu(scope.listview, explorer$context);
207
+ on("pointerdown")(scope.listview, function () {
208
+ if (document.activeElement !== scope.listview) scope.listview.focus();
209
+ })
210
+ onmounted(scope.listview, function () {
211
+ scope.listview.focus();
212
+ });
213
+
214
+ return page;
215
+ }
@@ -0,0 +1,78 @@
1
+ >lattice {
2
+ box-sizing: content-box;
3
+ outline: none;
4
+ margin-top: -@height;
5
+ padding-top: @height + 6px;
6
+
7
+ a {
8
+ vertical-align: top;
9
+ }
10
+ }
11
+
12
+ rect {
13
+ border: 1.5px solid #28c;
14
+ background: #28c2;
15
+ position: absolute;
16
+ display: block;
17
+ padding: 0;
18
+ z-index: 1;
19
+
20
+ &+lattice {
21
+ &:after {
22
+ display: block;
23
+ position: absolute;
24
+ left: 0;
25
+ top: 0;
26
+ bottom: 0;
27
+ right: 0;
28
+ content: '';
29
+ }
30
+ }
31
+ }
32
+
33
+ padding {
34
+ vertical-align: top;
35
+ border-right-width: 40px;
36
+ border-left-width: 10px;
37
+ }
38
+
39
+ >.address {
40
+ position: relative;
41
+ z-index: 3;
42
+ margin-left: 140px;
43
+ margin-top: -@height - 6px;
44
+ height: @height;
45
+ padding: 0 6px;
46
+ line-height: @height;
47
+
48
+ input {
49
+ width: 100%;
50
+ }
51
+ }
52
+
53
+ & {
54
+ height: 100%;
55
+ }
56
+
57
+ fileitem {
58
+ &:hover {
59
+ outline: 1.2px solid #28c;
60
+ }
61
+
62
+ &:active {
63
+ color: #28c;
64
+ outline: 2px solid;
65
+ }
66
+
67
+ &.focused {
68
+ background: #28c2;
69
+ outline: 1.2px solid #28c;
70
+ }
71
+
72
+ &[dropping] {
73
+ background-color: #28c4;
74
+ outline: 2px solid #28c;
75
+ }
76
+ }
77
+
78
+ @height: 44px;
@@ -42,7 +42,7 @@
42
42
  hotkey = hotkey.split(',');
43
43
  for (var k of hotkey) {
44
44
  k = k.trim().toLowerCase().replace(/[\+\_\s]+/g, '.');
45
- if (keymap[k]) console.warn("检查到两个项菜单使用了相同的快捷键", item, keymap[k]);
45
+ if (keymap[k]) console.warn("检查到两个菜单项使用了相同的快捷键", item, keymap[k]);
46
46
  keymap[k] = item;
47
47
  }
48
48
  item.hotkey = hotkey;
@@ -0,0 +1,9 @@
1
+ <svg width="92" height="92" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
2
+ style="fill: #666;" overflow="hidden" viewBox="12 135 92 92">
3
+
4
+ <g>
5
+ <path
6
+ d="M32 215 32 147 60 147 60 168 82 168 82 215 32 215ZM66 149.5 78.5 162 66 162 66 149.5ZM66 141 26 141 26 221 88 221 88 163 66 141Z"
7
+ fill-rule="evenodd" />
8
+ </g>
9
+ </svg>
@@ -0,0 +1,7 @@
1
+ <svg width="81" height="81" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
2
+ overflow="hidden" style="fill:#fc2;stroke: #f62;" viewBox="19 51 81 81">
3
+ <g>
4
+ <path
5
+ d="M90 120 24 120C21.8 120 20 118.2 20 116L20 68C20 65.8 21.8 64 24 64L42.8 64C43.6 64 44.4 64.2 45 64.7001L56 72 90 72C92.2 72 94 73.8 94 76L94 116C94 118.2 92.2 120 90 120Z" />
6
+ </g>
7
+ </svg>
@@ -1,14 +1,15 @@
1
+ var clean = removeFromList;
1
2
  function Cleanup(list) {
2
- function cleanup(target) {
3
+ if (isArray(list)) return function (target) {// 兼容老用法
3
4
  if (isNode(this) && !isNode(target)) {
4
5
  target = this;
5
6
  }
6
- for (var cx = list.length - 1; cx >= 0; cx--) {
7
- var element = list[cx];
8
- if (element === target) {
9
- list.splice(cx, 1);
10
- }
11
- }
7
+ clean(list, target);
8
+ return list.length;
9
+ }
10
+ if (isNode(list && list.target) && isNode(this)) {
11
+ var target = list.target, list = this.with;
12
+ clean(list, target);
13
+ if (!list.length) remove(this);
12
14
  }
13
- return cleanup;
14
15
  }
@@ -5,11 +5,12 @@ var reflect = {
5
5
  height: "width",
6
6
  X: "Y",
7
7
  Y: "X",
8
- "px": "px",
9
8
  "deltax": "deltay",
10
9
  "deltay": "deltax",
11
- "x":"y",
12
- "y":"x",
10
+ "x": "y",
11
+ "y": "x",
12
+ "up": "left",
13
+ "down": "right",
13
14
  Top: "Left",
14
15
  Left: "Top",
15
16
  top: "left",
@@ -19,7 +20,7 @@ var reflect = {
19
20
  right: "bottom",
20
21
  bottom: "right"
21
22
  };
22
- var regkeys = keys(reflect).map(a => /^[xy]$/.test(a) ? `\\b${a}` : a);
23
+ var regkeys = keys(reflect).map(a => /^[a-z]/.test(a) ? `\\b${a}(?![a-z])` : a);
23
24
  var regexps = new RegExp(regkeys.join("|"), "g");
24
25
  var rep = function (matched) {
25
26
  var searched = reflect[matched];
@@ -5,6 +5,8 @@ function unset(target, k) {
5
5
  if (target.hasAttribute(k)) target.removeAttribute(k);
6
6
  }
7
7
  function attr(target, key, value) {
8
+ if (value === false) value = null;
9
+ if (value === true) value = '';
8
10
  if (arguments.length === 3) {
9
11
  if (value === null) unset(target, key);
10
12
  else set(target, key, value);
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @param {any} item
3
+ * @param {Event} event
4
+ */
5
+ var emitEvent = function (item, event) {
6
+ if (event.defaultPrevented) return;
7
+ if (!getTargetIn(this, event.target) && !getTargetIn(event.target, this)) return;
8
+ event.preventDefault(true);
9
+ if (item.disabled) return;
10
+ active(this, item, "global", this.$src ? createItemTarget.call(this, item) : this);
11
+ };
12
+
13
+ var bindonly = function (elem, hotkey, item) {
14
+ hotkey = hotkey.toLowerCase().replace(/[\s\+\.\_]+/, '.');
15
+ return bind("keydown.only." + hotkey)(elem, isFunction(item) ? item : emitEvent.bind(elem, item));
16
+ }
17
+
18
+ function bindGlobalkey(elem, keymap, item) {
19
+ if (isString(keymap)) {
20
+ keymap = keymap.split(",");
21
+ }
22
+ if (isArray(keymap)) {
23
+ for (var k of keymap) bindonly(elem, k, item);
24
+ return;
25
+ }
26
+ if (elem.$keyoff) {
27
+ for (var off of elem.$keyoff) {
28
+ off();
29
+ }
30
+ }
31
+ if (!keymap) return;
32
+ var keyoff = [];
33
+ for (let k in keymap) {
34
+ keyoff.push(bindonly(elem, k, item));
35
+ }
36
+ elem.$keyoff = keyoff;
37
+ }
@@ -36,13 +36,11 @@ function confirm() {
36
36
  target = arg.currentTarget || arg.target;
37
37
  }
38
38
  });
39
- var element = div();
40
- element.innerHTML = `<div class=head></div><div class=body></div><div class=option></div>`;
39
+ var element = view();
40
+ element.innerHTML = `<div class=head></div><div class=body></div><div class=foot></div>`;
41
41
  var [head, body, option] = element.children;
42
42
  if (closable) {
43
- var closebtn = document.createElement("i");
44
- closebtn.title = "关闭";
45
- closebtn.className = "close";
43
+ var closebtn = drop();
46
44
  onclick(closebtn, function () {
47
45
  remove(element);
48
46
  });
@@ -78,7 +76,8 @@ function confirm() {
78
76
  options = ["确认 ", "取消"];
79
77
  }
80
78
  }
81
- var clickbtn = function () {
79
+ var clickbtn = function (event) {
80
+ event.preventDefault();
82
81
  if (element.hasAttribute("locked")) {
83
82
  return;
84
83
  }
@@ -129,9 +128,10 @@ function confirm() {
129
128
  else element.initialStyle = "opacity:0;transition:margin .3s,opacity .2s ease-out;";
130
129
  element.tabIndex = -1;
131
130
 
132
- setTimeout(function () {
131
+ Promise.resolve().then(function () {
133
132
  if (element.parentNode) return;
134
- popup(element, target || [.5, .5], target && 'rhomb');
133
+ element.mask = true;
134
+ popup(element, target || [.5, .5], target ? 'rhomb' : true);
135
135
  element.focus();
136
136
  if (!target) drag.on(head, element);
137
137
  else {
@@ -1,90 +1,16 @@
1
1
  & {
2
2
  position: absolute;
3
- margin: 0 auto;
4
- top: 50%;
5
- max-width: 100%;
6
- max-height: 100%;
7
- overflow: auto;
8
- cursor: default;
9
- box-sizing: border-box;
10
- background-color: #fff;
11
- border: 1px solid #999;
12
- box-shadow: 0 0 16px -6px rgba(0, 0, 0, .2);
13
- }
14
-
15
- &:focus {
16
3
  outline: none;
4
+ background: #fff;
17
5
  }
18
6
 
19
- div {
20
- box-sizing: border-box;
21
- }
22
-
23
- &>.head {
24
- line-height: 50px;
25
- min-height: 30px;
26
- position: relative;
27
- padding-left: 16px;
28
- position: sticky;
29
- top: 0;
30
- background: inherit;
31
- z-index: 2;
32
- font-size: 18px;
33
-
34
- .close {
35
- display: block;
36
- position: absolute;
37
- height: 32px;
38
- line-height: 32px;
39
- right: 0;
40
- top: 0;
41
- width: 44px;
42
- text-align: center;
43
- font-family: 'Times New Roman', Times, serif;
44
- font-size: 28px;
45
-
46
-
47
- &:hover {
48
- background: #f00;
49
- color: #fff;
50
- }
51
-
52
- &:active {
53
- background: #f008;
54
- }
55
-
56
- &:after {
57
- content: "×";
58
- }
59
- }
7
+ >.head,
8
+ >.foot {
9
+ border: none;
60
10
  }
61
11
 
62
12
  &>.body {
63
- padding: 10px 32px 20px;
64
- font-size: 16px;
65
-
66
- >* {
67
- max-width: 100%;
68
- }
69
- }
70
-
71
- &>.option {
72
- position: sticky;
73
- bottom: 0;
13
+ border-bottom: 30px solid transparent;
14
+ padding-left: 20px;
74
15
  background: inherit;
75
- text-align: center;
76
- padding: 10px 32px;
77
- white-space: nowrap;
78
-
79
- >div {
80
- display: inline-block;
81
- width: auto;
82
- min-width: 80px;
83
- position: relative;
84
- }
85
-
86
- .button {
87
- margin: 0 7px;
88
- padding: 0 8px;
89
- }
90
16
  }
@@ -1,5 +1,17 @@
1
- var change = function (data) {
2
- if (isNode(data)) {
1
+ var change = async function (data) {
2
+ if (!data) remove(this.with);
3
+ else if (isNode(data)) {
4
+ if (isElement(data) && this.$struct.copys) {
5
+ for (var c of this.$struct.copys) {
6
+ if (c.name === 'class') {
7
+ addClass(data, c.value);
8
+ }
9
+ else if (c.name === 'style') {
10
+ css(data, c.value);
11
+ }
12
+ else data.setAttribute(c.name, c.value);
13
+ }
14
+ }
3
15
  zimoli.global(data, this);
4
16
  }
5
17
  else zimoli.go(data, this.params, this);
@@ -19,8 +31,9 @@ function container(element) {
19
31
  if (element && element.hasAttribute('src')) {
20
32
  src = element.getAttribute('src');
21
33
  }
22
- element = document.createComment('container');
23
- element.src = src;
24
- element.renders = [gosrc];
25
- return element;
34
+ var comment = document.createComment('container');
35
+ comment.src = src;
36
+ comment.$struct = element.$struct;
37
+ comment.renders = [gosrc];
38
+ return comment;
26
39
  }
@@ -17,6 +17,13 @@ var createMenu = function (event, items) {
17
17
 
18
18
  return elem;
19
19
  }
20
+ async function emit(target, event) {
21
+ if (event.defaultPrevented) return;
22
+ if (!getTargetIn(target, event.target) && !getTargetIn(event.target, target)) return;
23
+ event.preventDefault();
24
+ if (isFunction(this.do)) await this.do(target, 'global');
25
+ dispatch(window, 'render');
26
+ }
20
27
  function contextmenu(target, menuItems) {
21
28
  var showContext = function (event) {
22
29
  var menu;
@@ -36,30 +43,40 @@ function contextmenu(target, menuItems) {
36
43
  };
37
44
  var menuHandle = 0;
38
45
  var tm;
39
- bindtouch(target, {
46
+ moveupon(target, {
40
47
  start(event) {
41
- if (event.defaultPrevented) return;
48
+ if (event.defaultPrevented || event.type === 'mousedown') return;
42
49
  clearTimeout(menuHandle);
43
- if (tm) remove(tm), tm = null;
44
50
  menuHandle = setTimeout(function () {
45
- tm = showContext(event);
51
+ var e = createEvent("contextmenu", true);
52
+ e.clientX = event.clientX;
53
+ e.clientY = event.clientY;
54
+ Object.defineProperty(e, "target", { value: event.target });
55
+ Object.defineProperty(e, "srcElement", { value: event.srcElement });
56
+ dispatch(event.target, e);
46
57
  }, 600);
47
58
  },
48
59
  move() {
49
- if (onclick.preventClick) return clearTimeout(menuHandle);
60
+ if (onclick.preventClick) {
61
+ if (tm) remove(tm);
62
+ return clearTimeout(menuHandle);
63
+ }
50
64
  },
51
65
  end(event) {
52
66
  clearTimeout(menuHandle);
53
- if (tm) {
54
- event.preventDefault();
55
- setTimeout(function () {
56
- if (!tm) return;
57
- tm.focus();
58
- onblur(tm, lazy(e => remove(tm)));
59
- }, 60);
60
- }
67
+ event.preventDefault();
68
+ _remove = function () { };
69
+ setTimeout(function () {
70
+ _remove = remove;
71
+ if (tm) tm.focus();
72
+ });
61
73
  }
62
- })
74
+ });
75
+ var _remove = remove;
76
+ var blur = lazy(function () {
77
+ if (document.activeElement === this) return;
78
+ _remove(this);
79
+ }, 60);
63
80
  on("contextmenu")(target, function (event) {
64
81
  if (event.defaultPrevented) return;
65
82
  event.preventDefault();
@@ -67,7 +84,10 @@ function contextmenu(target, menuItems) {
67
84
  tm = showContext(event);
68
85
  if (!tm) return;
69
86
  tm.focus();
70
- onblur(tm, lazy(e => remove(tm)));
87
+ onblur(tm, blur);
71
88
  });
89
+ if (isArray(menuItems)) for (var m of menuItems) {
90
+ if (m.hotkey) bindGlobalkey(target, m.hotkey, emit.bind(m, target));
91
+ }
72
92
  return sampleElement;
73
93
  }