efront 3.12.6 → 3.13.4

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 (61) hide show
  1. package/apps/pivot/api.yml +8 -0
  2. package/apps/pivot/home/welcome.html +1 -1
  3. package/apps/pivot/home/welcome.js +6 -9
  4. package/apps/pivot/log/boot.html +2 -0
  5. package/apps/pivot/log/boot.js +39 -0
  6. package/apps/pivot/log/boot.less +11 -0
  7. package/apps/pivot/log/count.html +5 -0
  8. package/apps/pivot/log/count.js +22 -0
  9. package/apps/pivot/log/count.less +16 -0
  10. package/apps/pivot/main.js +9 -10
  11. package/apps/pivot/menu.yml +8 -2
  12. package/apps/pivot/proxy/edit.js +1 -0
  13. package/apps/pivot/proxy/list.js +12 -0
  14. package/apps/pivot/share/list.less +0 -4
  15. package/apps/pivot/user/edit.js +1 -0
  16. package/apps/pivot/user/list.js +4 -0
  17. package/apps/pivot/user/tag/edit.js +1 -0
  18. package/apps/pivot/user/tag/list.js +3 -0
  19. package/coms/basic/cross_.js +8 -1
  20. package/coms/basic/encodePack.js +2 -9
  21. package/coms/basic/parseURL_test.js +2 -0
  22. package/coms/basic/parseYML.js +1 -1
  23. package/coms/basic/renderExpress.js +1 -1
  24. package/coms/frame/route.js +4 -0
  25. package/coms/pivot/plist.js +1 -1
  26. package/coms/zimoli/AudioContext_test.html +1 -1
  27. package/coms/zimoli/AudioContext_test.js +3 -3
  28. package/coms/zimoli/bind.js +4 -2
  29. package/coms/zimoli/cloneVisible.js +9 -2
  30. package/coms/zimoli/cross.js +2 -3
  31. package/coms/zimoli/data.js +22 -4
  32. package/coms/zimoli/drag.js +3 -2
  33. package/coms/zimoli/field.html +15 -10
  34. package/coms/zimoli/menu.js +33 -13
  35. package/coms/zimoli/menu.less +31 -9
  36. package/coms/zimoli/menuItem.js +1 -1
  37. package/coms/zimoli/menuList.html +5 -3
  38. package/coms/zimoli/menuList.js +63 -28
  39. package/coms/zimoli/menuList.less +5 -0
  40. package/coms/zimoli/model.js +22 -1
  41. package/coms/zimoli/on.js +5 -3
  42. package/coms/zimoli/picture.js +30 -335
  43. package/coms/zimoli/picture_.js +356 -0
  44. package/coms/zimoli/prompt.js +3 -1
  45. package/coms/zimoli/render.js +22 -10
  46. package/coms/zimoli/renderDefaults.js +1 -0
  47. package/coms/zimoli/search.js +5 -4
  48. package/coms/zimoli/select.js +7 -3
  49. package/coms/zimoli/selectList.js +7 -7
  50. package/coms/zimoli/selectListEdit.js +1 -1
  51. package/coms/zimoli/success.js +4 -0
  52. package/coms/zimoli/success.less +13 -0
  53. package/coms/zimoli/table.html +6 -8
  54. package/coms/zimoli/table.js +25 -2
  55. package/coms/zimoli/table.less +24 -4
  56. package/coms/zimoli/view.less +4 -0
  57. package/package.json +1 -1
  58. package/public/efront.js +1 -1
  59. package/apps/pivot/home/short.html +0 -1
  60. package/apps/pivot/home/short.js +0 -5
  61. package/apps/pivot/home/short.less +0 -1
@@ -0,0 +1,356 @@
1
+ var mountedPictures = [];
2
+ on("resize")(window, function () {
3
+ mountedPictures.forEach(a => a.update());
4
+ });
5
+ var getstation = function (n, s) {
6
+ var scale = Math.pow(10, Math.round(Math.log(n) / Math.log(10)));
7
+ var step;
8
+ if (n / scale < 1) {
9
+ step = s ? .01 : .05;
10
+ } else {
11
+ step = s ? .05 : .1;
12
+ }
13
+ step = step * scale;
14
+ n = Math.round(n / step) * step;
15
+ return n;
16
+ };
17
+ var trimCoord = move.trimCoord;
18
+ var isequal = (a, b) => a === b || Math.abs((a - b) / (a + b)) < 1e-12;
19
+ function picture_(image = document.createElement("div")) {
20
+ var image_width, image_height;
21
+ var scaled, x, y, min_scale, loaded_scale, locked_scale, click_scale, loaded_x, loaded_y;
22
+ var origin_width, origin_height;
23
+ var max_scale = 10 * devicePixelRatio;
24
+ var shape = function () {
25
+ image.shape(x, y, scaled / devicePixelRatio, origin_rotate);
26
+ };
27
+ image.reshape = shape;
28
+ var park = function () {
29
+ if (image.park) image.park(x, y, scaled / devicePixelRatio, origin_rotate);
30
+ };
31
+ var setInitParams = function () {
32
+ if (!image.width) return;
33
+ image_width = image.width / devicePixelRatio;
34
+ image_height = image.height / devicePixelRatio;
35
+ origin_width = image.clientWidth;
36
+ origin_height = image.clientHeight;
37
+ origin_rotate = 0;
38
+ locked_scale = loaded_scale = Math.min(image.clientHeight / image_height, image.clientWidth / image_width);
39
+ if (loaded_scale >= 0.9) {
40
+ if (loaded_scale < 1.2) {
41
+ click_scale = 1;
42
+ loaded_scale = .8;
43
+ } else if (loaded_scale < max_scale) {
44
+ click_scale = loaded_scale;
45
+ loaded_scale = 1;
46
+ } else {
47
+ click_scale = max_scale;
48
+ loaded_scale = 1;
49
+ }
50
+ } else {
51
+ click_scale = 1;
52
+ }
53
+ loaded_x = (image.clientWidth - image_width * loaded_scale) / 2;
54
+ loaded_y = (image.clientHeight - image_height * loaded_scale) / 2;
55
+ min_scale = loaded_scale * .75;
56
+ scaled = loaded_scale;
57
+ x = loaded_x;
58
+ y = loaded_y;
59
+ updatexy();
60
+ set_unlock();
61
+ };
62
+ var set_unlock = function () {
63
+ if (!loaded_scale) return;
64
+ fixpos();
65
+ shape();
66
+ };
67
+
68
+ on("append")(image, setInitParams);
69
+
70
+ on("append")(image, function () {
71
+ mountedPictures.push(image);
72
+ });
73
+ on("remove")(image, function () {
74
+ removeFromList(mountedPictures, image);
75
+ });
76
+ image.init = setInitParams;
77
+ image.locked = false;
78
+ var last_click_time = 0;
79
+
80
+ on("click")(image, function (event) {
81
+ var time = +new Date;
82
+ var delta_time = time - last_click_time;
83
+ last_click_time = time;
84
+ if (delta_time > 300) return;
85
+ var image = this;
86
+ var __scaled = scaled, _x = x, _y = y;
87
+ setInitParams();
88
+ image.locked = isequal(__scaled, loaded_scale) && isequal(loaded_x, x) && isequal(loaded_y, y);
89
+ var layerx = event.offsetX || 0;
90
+ var layery = event.offsetY || 0;
91
+ if (layerx)
92
+ if (image.locked) {
93
+ var width = image_width * loaded_scale, height = image_height * loaded_scale;
94
+ if (layerx > loaded_x + width || layerx < loaded_x || width < image.offsetWidth >> 2) {
95
+ layerx = loaded_x + width / 2;
96
+ }
97
+ if (layery > loaded_y + height || layery < loaded_y || height < image.offsetHeight >> 2) {
98
+ layery = loaded_y + height / 2;
99
+ }
100
+ scale(layerx, layery, click_scale / loaded_scale);
101
+ } else {
102
+ set_unlock();
103
+ }
104
+ });
105
+ image.getScale = function () {
106
+ if (!this.locked && !loaded_scale) {
107
+ setInitParams();
108
+ }
109
+ return +String(+scaled + 0.00005).slice(0, 6);
110
+ };
111
+ var fixpos = function () {
112
+ var width = image_width * scaled;
113
+ var height = image_height * scaled;
114
+ var r = image.rotate | 0;
115
+ var [, , w, h] = getrotatedltwh(r);
116
+ var x0 = x + (width - w) / 2;
117
+ var y0 = y + (height - h) / 2;
118
+ var [x1, y1] = trimCoord([image.clientWidth, image.clientHeight], [x0, y0, w, h], -1);
119
+ x += x1 - x0;
120
+ y += y1 - y0;
121
+ };
122
+ var scale = function (layerx, layery, ratio) {
123
+ if (!image.locked) return;
124
+ scaled *= ratio;
125
+ x = (x - layerx) * ratio + layerx;
126
+ y = (y - layery) * ratio + layery;
127
+ shape();
128
+ };
129
+ var touch = function ([x1, y1, x2, y2], [m1, n1, m2, n2]) {
130
+ var l1 = Math.sqrt(Math.pow(m1 - m2, 2) + Math.pow(n1 - n2, 2));
131
+ var l2 = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
132
+ var scale = l1 / l2;
133
+ if (scaled >= max_scale * 1.1 && scale > 1) return;
134
+ if (scaled <= min_scale && scale < 1) return;
135
+ scaled *= scale;
136
+ var centerx = (x1 + x2) / 2;
137
+ var centery = (y1 + y2) / 2;
138
+ var centerm = (m1 + m2) / 2;
139
+ var centern = (n1 + n2) / 2;
140
+ x = (x - centerx) * scale + centerm;
141
+ y = (y - centery) * scale + centern;
142
+ shape();
143
+ };
144
+ var recover = function (change) {
145
+ var aimed_scale = getstation(scaled);
146
+ if (aimed_scale !== scaled) {
147
+ change = true;
148
+ x = (x - image.clientWidth / 2) / scaled * aimed_scale + image.clientWidth / 2;
149
+ y = (y - image.clientHeight / 2) / scaled * aimed_scale + image.clientHeight / 2;
150
+ scaled = aimed_scale;
151
+ }
152
+ if (scaled <= loaded_scale * 1.2) {
153
+ scaled = loaded_scale;
154
+ x = loaded_x;
155
+ y = loaded_y;
156
+ change = true;
157
+ }
158
+ if (scaled > max_scale) {
159
+ change = true;
160
+ x = (x - image.clientWidth / 2) * max_scale / scaled + image.clientWidth / 2;
161
+ y = (y - image.clientHeight / 2) * max_scale / scaled + image.clientHeight / 2;
162
+ scaled = max_scale;
163
+ }
164
+ var saved_x = x, saved_y = y;
165
+ fixpos();
166
+ if (change || saved_x !== x || saved_y !== y) {
167
+ park();
168
+ }
169
+ };
170
+ var move = inertia(function (deltax, deltay) {
171
+ var saved_x = x, saved_y = y;
172
+ x += deltax, y += deltay;
173
+ fixpos();
174
+ shape();
175
+ if (saved_x === x && saved_y === y) return false;
176
+ });
177
+ var saved_event, wheeltime;
178
+ onmousewheel(image, function (event) {
179
+ var { offsetX: layerX, offsetY: layerY, deltaY } = event;
180
+ if (this.locked) event.preventDefault();
181
+ if (!deltaY) return;
182
+ if (!this.locked) setInitParams();
183
+ this.locked = true;
184
+ var ratio = Math.pow(0.99, 20 * Math.atan(deltaY / 20));
185
+ var __scaled = scaled;
186
+ __scaled *= ratio;
187
+ if (__scaled > max_scale && ratio > 1) {
188
+ __scaled = max_scale;
189
+ }
190
+ if (__scaled < min_scale && ratio < 1) {
191
+ __scaled = min_scale;
192
+ }
193
+ ratio = __scaled / scaled;
194
+ scale(layerX, layerY, ratio);
195
+ });
196
+ moveupon(image, {
197
+ start(event) {
198
+ event.preventDefault();
199
+ saved_event = event;
200
+ event.moveLocked = scaled > locked_scale;
201
+ if (!this.locked) {
202
+ setInitParams();
203
+ }
204
+ move.reset();
205
+ },
206
+ move(event) {
207
+ if (event.moveLocked) return;
208
+ event.moveLocked = scaled > locked_scale;
209
+ event.preventDefault();
210
+ if (event.touches && saved_event.touches) {
211
+ if (event.touches.length !== saved_event.touches.length) {
212
+ saved_event = event;
213
+ return;
214
+ }
215
+
216
+ switch (event.touches.length) {
217
+ case 1:
218
+ if (!this.locked) return;
219
+ break;
220
+ case 2:
221
+ this.locked = true;
222
+ event.moveLocked = true;
223
+ var [xy1, xy2] = saved_event.touches;
224
+ var [mn1, mn2] = event.touches;
225
+ var { left, top } = getScreenPosition(image);
226
+ top += image.clientTop;
227
+ left += image.clientLeft;
228
+ touch(
229
+ [xy1.clientX - left, xy1.clientY - top, xy2.clientX - left, xy2.clientY - top],
230
+ [mn1.clientX - left, mn1.clientY - top, mn2.clientX - left, mn2.clientY - top]
231
+ );
232
+ saved_event = event;
233
+ return;
234
+ }
235
+ }
236
+ if (event.which === 3) {
237
+ event.moveLocked = true;
238
+ rotatexy(saved_event.clientX, saved_event.clientY, event.clientX, event.clientY);
239
+ }
240
+ else {
241
+ if (!this.locked) return;
242
+ var deltax = event.clientX - saved_event.clientX,
243
+ deltay = event.clientY - saved_event.clientY;
244
+ move(deltax, deltay);
245
+ }
246
+ saved_event = event;
247
+ },
248
+ end(event) {
249
+ if (saved_event) {
250
+ if (event.timeStamp - saved_event.timeStamp > 120) {
251
+ move.reset();
252
+ }
253
+ }
254
+ saved_event = null;
255
+ event.moveLocked = scaled >= locked_scale;
256
+
257
+ if (this.locked && onclick.preventClick) move.smooth(recover);
258
+ }
259
+ });
260
+ var origin_rotate = 0;
261
+ var rotatexy = function (x1, y1, x2, y2) {
262
+ var centerx = image.clientWidth / 2, centery = image.clientHeight / 2;
263
+ var deltax = x2 - x1, deltay = y2 - y1;
264
+ var rx = x1 - centerx, ry = y1 - centery;
265
+ var sign = -ry * deltax + rx * deltay;
266
+ var delta = 90 * Math.sqrt(deltax * deltax + deltay * deltay) / Math.sqrt(rx * rx + ry * ry);
267
+ if (delta > 10) delta = 10;
268
+ if (sign) image.rotateBy(sign > 0 ? delta : -delta);
269
+ }
270
+ var updatexy = function () {
271
+ var deg = image.rotate - origin_rotate;
272
+ if (isFinite(deg)) {
273
+ origin_rotate = image.rotate;
274
+ [x, y] = getrotatedltwh(deg, scaled);
275
+ }
276
+ };
277
+ var getrotatedltwh = function (a, s = scaled) {
278
+ var w = image_width * s;
279
+ var h = image_height * s;
280
+ var c = [image.clientWidth / 2, image.clientHeight / 2];
281
+ var m = x + w / 2;
282
+ var n = y + h / 2;
283
+ var [c1, c2] = rotate([m, n], -a, c);
284
+ c1 -= w / 2;
285
+ c2 -= h / 2;
286
+ var a = origin_rotate;
287
+ var l = c[0] - w / 2;
288
+ var r = l + w;
289
+ var t = c[1] - h / 2;
290
+ var b = t + h;
291
+ var [x1, y1] = rotate([l, t], a, c);
292
+ var [x2, y2] = rotate([r, t], a, c);
293
+ var [x3, y3] = rotate([l, b], a, c);
294
+ var [x4, y4] = rotate([r, b], a, c);
295
+ var l = Math.min(x1, x2, x3, x4);
296
+ var t = Math.min(y1, y2, y3, y4);
297
+ var w = Math.max(x1, x2, x3, x4) - l;
298
+ var h = Math.max(y1, y2, y3, y4) - t;
299
+ return [c1, c2, w, h];
300
+ };
301
+ image.update = function (animate) {
302
+ if (image.locked) {
303
+ updatexy();
304
+ x += (image.clientWidth - origin_width) / 2;
305
+ y += (image.clientHeight - origin_height) / 2;
306
+ origin_height = image.clientHeight;
307
+ origin_width = image.clientWidth;
308
+ if (animate !== false) fixpos();
309
+ shape();
310
+ return;
311
+ }
312
+ setInitParams();
313
+ if (animate !== false) {
314
+ recover();
315
+ } else {
316
+ if (animate !== false) fixpos();
317
+ shape();
318
+ }
319
+
320
+ };
321
+ image.rotateTo = function (deg) {
322
+ this.rotate = deg;
323
+ this.update();
324
+ };
325
+ image.rotateBy = function (deg) {
326
+ var r = this.rotate | 0;
327
+ if (deg === 90 || deg === -90) {
328
+ r += deg;
329
+ if (deg > 0) {
330
+ // 九进八舍
331
+ var a = r / 90;
332
+ if (Math.ceil(a) - a < .01) {
333
+ r = Math.ceil(a) * 90;
334
+ } else {
335
+ r = Math.floor(a) * 90;
336
+ }
337
+ } else {
338
+ // 一进零舍
339
+ var a = r / 90;
340
+ if (Math.ceil(a) - a > .01) {
341
+ r = Math.ceil(a) * 90;
342
+ } else {
343
+ r = Math.floor(a) * 90;
344
+ }
345
+ }
346
+ } else {
347
+ r += deg;
348
+ }
349
+ this.rotate = r;
350
+ this.update(deg === 90 || deg === -90);
351
+ };
352
+ on("contextmenu")(image, function (e) {
353
+ if (onclick.preventClick) e.preventDefault();
354
+ });
355
+ return image;
356
+ }
@@ -25,8 +25,10 @@ function prompt(msg = "请输入", check) {
25
25
  });
26
26
  })
27
27
  on("mousedown")(c, e => e.target !== ipt && e.preventDefault() | ipt.focus());
28
- on("keydown.enter")(c, function () {
28
+ on("keydown.enter")(c, function (event) {
29
+ if (event.defaultPrevented) return;
29
30
  if (check && check(ipt.value) === false) return;
31
+ event.preventDefault();
30
32
  oked = true;
31
33
  remove(c);
32
34
  fire();
@@ -1,6 +1,15 @@
1
1
  var hasOwnProperty = {}.hasOwnProperty;
2
2
  var renderElements = Object.create(null);
3
3
  var presets = Object.create(null);
4
+ presets.template = function (t) {
5
+ var node = document.createElement("div");
6
+ var comment = document.createComment('template');
7
+ node.innerHTML = t.innerHTML;
8
+ comment.with = [].slice.call(node.childNodes, 0);
9
+ renderElement(comment.with, t.$scope, t.$parentScopes);
10
+ remove(node.childNodes);
11
+ return comment;
12
+ };
4
13
  window.renderElements = renderElements;
5
14
  var renderidOffset = 10;
6
15
  var renderidClosed = 0;
@@ -70,7 +79,6 @@ var initialComment = function (renders, type, expression) {
70
79
  onremove(comment, removeRenderElement);
71
80
  appendChild.after(this, comment);
72
81
  if (!/if/i.test(type)) remove(this);
73
- this.with = comment;
74
82
  rebuild(comment);
75
83
  return comment;
76
84
  };
@@ -214,17 +222,12 @@ var createIf = function (search, id = 0) {
214
222
  var element = elements[cx];
215
223
  if (cx === shouldMount) {
216
224
  appendChild.before(this, element);
217
- element.with = this;
218
225
  if (element.renderid < 0) {
219
226
  element.renderid = id;
220
- var w = element.with;
221
- delete element.with;
222
- element = render(element);
223
- element.with = w;
227
+ elements[cx] = render(element);
224
228
  }
225
229
  }
226
230
  else {
227
- delete element.with;
228
231
  remove(element);
229
232
  }
230
233
  }
@@ -624,7 +627,7 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
624
627
  if (parentNode.renderid > 1 || parentNode.isMounted) element.renderid = 2;
625
628
  }
626
629
  element.renders = element.renders ? [].concat(element.renders) : [];
627
- var { ons, copys, attrs, props, binds, context: withContext } = element.$struct;
630
+ var { ons, copys, attrs, props, binds, context: withContext, ids } = element.$struct;
628
631
  delete element.$struct;
629
632
  if (binds.src) {
630
633
  element.$src = parseRepeat(binds.src);
@@ -672,7 +675,7 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
672
675
  }
673
676
  }
674
677
  }
675
- if (element.children.length) renderElement(element.children, scope, parentScopes);
678
+ if (element.children && element.children.length) renderElement(element.children, scope, parentScopes);
676
679
  if (!isFirstRender) return element;
677
680
  for (var k in binds) {
678
681
  if (directives.hasOwnProperty(k)) {
@@ -698,6 +701,9 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
698
701
  if (element.isMounted || element.renderid > 1) addRenderElement.call(element);
699
702
  }
700
703
  if (elementid) scope[elementid] = element;
704
+ for (var id of ids) {
705
+ scope[id] = element;
706
+ }
701
707
  return element;
702
708
  }
703
709
  function renderStructure(element, scope, parentScopes = []) {
@@ -721,8 +727,14 @@ function renderStructure(element, scope, parentScopes = []) {
721
727
  var binds = {};
722
728
  var attr1 = {};
723
729
  var props = {};
730
+ var ids = [];
724
731
  for (var attr of attrs) {
725
732
  var { name, value } = attr;
733
+ if (/^#/.test(name)) {
734
+ ids.push(name.slice(1));
735
+ element.removeAttribute(name);
736
+ continue;
737
+ };
726
738
  if (/^(?:class|style|src|\:|placeholder)$/i.test(name)) {
727
739
  copys.push(attr);
728
740
  continue;
@@ -771,7 +783,7 @@ function renderStructure(element, scope, parentScopes = []) {
771
783
  props[name.replace(/\-(\w)/g, (_, w) => w.toUpperCase())] = value === "" ? true : value;
772
784
  }
773
785
  }
774
- if (!element.$struct) element.$struct = { ons, copys, binds, attrs: attr1, props, context: withContext };
786
+ if (!element.$struct) element.$struct = { ons, copys, binds, attrs: attr1, props, context: withContext, ids };
775
787
  if (element.renderid <= -1) createStructure.call(element, types.if, types.repeat, withContext);
776
788
  }
777
789
  function render(element, scope, parentScopes) {
@@ -34,6 +34,7 @@ extend(renderDefaults, {
34
34
  pic: img,
35
35
  image,
36
36
  back,
37
+ success,
37
38
  switch: swap,
38
39
  swap,
39
40
  password,
@@ -1,10 +1,11 @@
1
- function search(seartext, options) {
1
+ function search(seartext, options, path = "name") {
2
2
  if (options instanceof Array) {
3
3
  var hasFullmatch = false;
4
4
  var a = options.map(o => {
5
- if (o.name === seartext) hasFullmatch = true;
6
- var [power, m] = mark.power(o.name, seartext);
7
- return { power, name: m, value: o.value };
5
+ var name = seek(o, path);
6
+ if (name === seartext) hasFullmatch = true;
7
+ var [power, m] = mark.power(name, seartext);
8
+ return { power, [path]: m, value: o.value, item: o };
8
9
  }).filter(a => a.power > 0);
9
10
  a.sort(function (a, b) {
10
11
  return b.power - a.power;
@@ -24,6 +24,10 @@ var _remove = function () {
24
24
  var preventDefault = function (event) {
25
25
  event.preventDefault();
26
26
  };
27
+ var preventDefault1 = function (event) {
28
+ if (saved_list) return;
29
+ event.preventDefault();
30
+ }
27
31
  var lastTimeClick = 0;
28
32
  var removeByBlur = function () {
29
33
  if (!getTargetIn(this, document.activeElement)) _remove();
@@ -71,8 +75,8 @@ function select(target, list, removeOnSelect, direction) {
71
75
  target.innerHTML = `<option selected value="${this.value}">${this.name || this.value}</option>`
72
76
  }
73
77
  target.value = this.value;
74
- dispatch(target, "change");
75
78
  }
79
+ dispatch(target, "change");
76
80
  }
77
81
  };
78
82
  var onlistclick = function (event) {
@@ -96,8 +100,8 @@ function select(target, list, removeOnSelect, direction) {
96
100
  }
97
101
  on("keydown.up")(target, preventDefault);
98
102
  on("keydown.down")(target, preventDefault);
99
- on("keydown.enter")(target, preventDefault);
100
- on("keydown.space")(target, preventDefault);
103
+ on("keydown.enter")(target, preventDefault1);
104
+ on("keydown.space")(target, preventDefault1);
101
105
  var pop = function () {
102
106
  if (saved_list !== list) mousedown.call(this);
103
107
  };
@@ -60,7 +60,7 @@ function main() {
60
60
  function createItem(option) {
61
61
  var key = option.key || option.value;
62
62
  if (key in itemMap) return itemMap[key];
63
- var item = itemMap[option.value] = document.createElement('div');
63
+ var item = itemMap[key] = document.createElement('div');
64
64
  item.setAttribute("item", '');
65
65
  item.innerHTML = option.innerHTML || option.name;
66
66
  item.name = option.name || option.innerHTML;
@@ -78,12 +78,12 @@ function main() {
78
78
  iconed = icon;
79
79
  if (multiple) {
80
80
  item.setAttribute("selected", "");
81
- page.value.push(option.value);
81
+ page.value.push(key);
82
82
  }
83
83
  else {
84
84
  item.setAttribute("selected", "");
85
85
  page.activeNode = item;
86
- page.value = option.value
86
+ page.value = key
87
87
  }
88
88
  }
89
89
  if (option.disabled) {
@@ -142,10 +142,9 @@ function main() {
142
142
  if (a in itemMap) return false;
143
143
  cast(page.target, "add-option", a);
144
144
  children.push({ name: a, key: a });
145
- page.insertBefore(createItem({
146
- name: a,
147
- value: a,
148
- }), adder);
145
+ remove(page.children);
146
+ page.go(children.length - 1);
147
+ appendChild(page, adder);
149
148
  break;
150
149
  case this.children[1]:
151
150
  var options = [].slice.call(children, 0, children.length);
@@ -216,6 +215,7 @@ function main() {
216
215
  moveFocus(0);
217
216
  })
218
217
  var enter = function (e) {
218
+ if (e.defaultPrevented) return;
219
219
  e.preventDefault();
220
220
  var e = page.getIndexedElement(focus);
221
221
  if (e) e.click();
@@ -14,7 +14,7 @@ function main(options) {
14
14
  },
15
15
  del(o) {
16
16
  for (var cx = 0, dx = options.length; cx < dx; cx++) {
17
- if (options[cx].value === o.value) {
17
+ if (options[cx] === o || options[cx] === o.item) {
18
18
  var i = cx;
19
19
  break;
20
20
  }
@@ -0,0 +1,4 @@
1
+ function success(e) {
2
+ if (!e) e = document.createElement('success');
3
+ return e;
4
+ }
@@ -0,0 +1,13 @@
1
+ & {
2
+ background: #2942;
3
+ color: #294;
4
+ font-size: 24px;
5
+ line-height: 2;
6
+ text-align: center;
7
+ display: block;
8
+ font-family: "仿宋", sans-serif;
9
+
10
+ &:before {
11
+ content: " ✓ ";
12
+ }
13
+ }
@@ -1,16 +1,14 @@
1
- <thead>
2
- <tr>
3
- <td -repeat="f in fields track by f.id" :style="{width:f.width}"><i -if="f.icon"
1
+ <tbody -src="d in data" :style="{'max-height':((innerHeight-46)/32|0)*32+36}">
2
+ <tr thead #adapter insert>
3
+ <td -repeat="f in fields track by f.id" :style="{width:f.width}" @dblclick="sort(f)"><i -if="f.icon"
4
4
  -class="f.icon"></i></span><span -if="f.name" -html="f.name"></span>
5
5
  </td>
6
6
  </tr>
7
- </thead>
8
- <tbody -src="d in data">
9
7
  <tr>
10
8
  <td -repeat="f in fields">
11
- <model -if="f.key" :field=f :data=d readonly ></model>
12
- <a on-click="o.do(d)" -if="!f.key&&f.options&&(!o.when||o.when(d))" _type="o.type instanceof Function?o.type(d):o.type"
13
- -repeat="o in f.options">
9
+ <model -if="f.key" :field=f :data=d readonly></model>
10
+ <a on-click="o.do(d)" -if="!f.key&&f.options&&(!o.when||o.when(d))"
11
+ _type="o.type instanceof Function?o.type(d):o.type" -repeat="o in f.options">
14
12
  <span -text="o.name instanceof Function?o.name(d):o.name"></span>
15
13
  </a>
16
14
  </td>
@@ -169,8 +169,12 @@ function table(elem) {
169
169
  move: resizeTarget,
170
170
  });
171
171
  onmousemove(tableElement, function (event) {
172
- if (!thead) [thead] = table.getElementsByTagName("thead");
172
+ if (!thead) {
173
+ [thead] = table.getElementsByTagName("thead");
174
+ if (!thead) thead = table.querySelector('[thead]');
175
+ }
173
176
  if (!getTargetIn(thead, event.target)) return;
177
+
174
178
  var tds = getTargetIn(cellMatchManager, event.target);
175
179
  if (!isArray(tds)) tds = [];
176
180
  tds.map(function (td) {
@@ -193,7 +197,10 @@ function table(elem) {
193
197
  var table = tableElement;
194
198
  var thead;
195
199
  var cellMatchManager = function (element) {
196
- if (!thead) [thead] = table.getElementsByTagName("thead");
200
+ if (!thead) {
201
+ [thead] = table.getElementsByTagName("thead");
202
+ if (!thead) thead = table.querySelector('[thead]');
203
+ }
197
204
  if (table.resizing) return false;
198
205
  if (!getTargetIn(thead, element)) return false;
199
206
  if (!tdElementReg.test(element.tagName)) return false;
@@ -214,8 +221,24 @@ function table(elem) {
214
221
  render(this, {
215
222
  fields,
216
223
  tbody: list,
224
+ innerHeight: {
225
+ valueOf() {
226
+ return innerHeight - getScreenPosition(table).top;
227
+ }
228
+ },
217
229
  data,
230
+ adapter: null,
218
231
  model,
232
+ sort(f) {
233
+ f.sign = f.sign > 0 ? -1 : 1;
234
+ data.sort(function (a, b) {
235
+ a = seek(a, f.key);
236
+ b = seek(b, f.key);
237
+ if (a > b) return f.sign;
238
+ if (a < b) return -f.sign;
239
+ return 0;
240
+ });
241
+ },
219
242
  setWidth(target, f) {
220
243
  css(target, { width: f.width });
221
244
  },