efront 3.35.2 → 3.35.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.
@@ -41,6 +41,7 @@ var markRowTds = function (tr, deltas, colstart, colend) {
41
41
  };
42
42
  var forEachRow = function (tbody, call) {
43
43
  for (var tr of tbody.children) {
44
+ if (isTfoot(tr)) continue;
44
45
  if (isTableRow(tr)) {
45
46
  call(tr);
46
47
  }
@@ -86,9 +87,12 @@ var getTbody = function (table) {
86
87
  if (/^tbody$/i.test(c.tagName) || c.hasAttribute("tbody")) return c;
87
88
  }
88
89
  };
90
+ var isTfoot = function (c) {
91
+ return /^tfoot$/i.test(c.tagName) || c.hasAttribute("tfoot");
92
+ }
89
93
  var getTfoot = function (table) {
90
94
  for (var c of table.children) {
91
- if (/^tfoot$/i.test(c.tagName) || c.hasAttribute("tfoot")) return c;
95
+ if (isTfoot(c)) return c;
92
96
  }
93
97
  };
94
98
  var isTableRow = function (e) {
@@ -106,6 +110,7 @@ var resizeColumn = function (target, targetW) {
106
110
  resizeT(tr, tr.offsetWidth + deltaW);
107
111
  });
108
112
  for (var c of this.children) {
113
+ if (isTfoot(c)) continue;
109
114
  if (!isTableRow(c)) {
110
115
  var tr = c.querySelector('tr');
111
116
  if (!tr) continue;
@@ -230,8 +235,9 @@ function enrichField(f) {
230
235
  f.fixed = true;
231
236
  }
232
237
  }
233
- var tbodyHeight = function (tbody) {
234
- return { 'max-height': ((innerHeight - getScreenPosition(tbody).top - 8) / 36 | 0) * 36 }
238
+ var tbodyHeight = function (tbody, hasFoot) {
239
+ var rowHeight = calcPixel(36);
240
+ return { 'max-height': ((innerHeight - (!!hasFoot ? rowHeight : 6) - getScreenPosition(tbody).top - 10) / rowHeight | 0) * rowHeight }
235
241
  };
236
242
 
237
243
  var setFixed = function (children, scrolled, left, borderRight) {
@@ -247,18 +253,17 @@ var setFixed = function (children, scrolled, left, borderRight) {
247
253
  for (var c of children) {
248
254
  var pc = getScreenPosition(c);
249
255
  var isfixed = c.hasAttribute('fixed');
250
- if (fixedWidth + scrolled > offset && fixedWidth + pc.width < this.clientWidth / 3) {
251
- if (isfixed) {
256
+ if (isfixed) {
257
+ if (fixedWidth + scrolled > offset && fixedWidth + pc.width < this.clientWidth / 3) {
252
258
  css(c, { [left]: scrolled - offset + fixedWidth, [borderRight]: '' });
253
259
  fixedElements.push(c);
254
260
  fixedWidth += pc.width;
255
261
  }
256
- }
257
- else {
258
- setBorderRight(fixedElements);
259
- if (isfixed && c.style[left]) {
260
- css(c, { [left]: '', [borderRight]: '' })
261
- fixedElements.push(c);
262
+ else {
263
+ if (c.style[left]) {
264
+ css(c, { [left]: '', [borderRight]: '' })
265
+ fixedElements.push(c);
266
+ }
262
267
  }
263
268
  }
264
269
  offset += pc.width;
@@ -275,18 +280,34 @@ var setFixed = function (children, scrolled, left, borderRight) {
275
280
  };
276
281
 
277
282
 
278
- var setFixedColumn = function () {
283
+ var setFixedColumn = function (remark) {
279
284
  var thead = getThead(this);
280
285
  if (!thead) return;
286
+ remark = remark === true;
287
+ if (remark) remark = [], forEachRow(thead, function (tr) {
288
+ markRowTds(tr, remark);
289
+ });
281
290
  if (!isTableRow(thead)) thead = thead.querySelector('tr');
282
291
  var children = Array.prototype.slice.call(thead.children);
283
292
  var lastChild = children[children.length - 1];
293
+ var lastFieldChild = children[children.length - 2];
294
+ if (children.length <= 2) lastFieldChild = null;
284
295
  if (!lastChild) return;
296
+ var cindex = children.length - 1;
297
+ if (lastFieldChild) css(lastChild, { width: 0 }), lastChild = lastFieldChild, cindex = children.length - 2;
285
298
  var deltaW = thead.scrollWidth - lastChild.offsetWidth;
286
- if (this.clientWidth > deltaW + 200) {
299
+ if (this.clientWidth > deltaW + lastChild.offsetWidth) {
287
300
  css(lastChild, { width: this.clientWidth - deltaW });
288
301
  css(thead, { width: this.clientWidth });
289
302
  resizeColumn.call(this, lastChild, this.clientWidth - deltaW);
303
+ remark = true;
304
+ }
305
+ if (remark) {
306
+ var tbody = getTbody(this);
307
+ forEachRow(tbody, function (tr) {
308
+ css(tr.children[cindex], lastChild.style);
309
+ });
310
+ css(tbody, { width: thead.offsetWidth });
290
311
  }
291
312
  setFixed.call(this, children, this.scrollLeft, 'left', 'borderRight');
292
313
  setFixed.call(this, children.reverse(), this.scrollWidth - this.clientWidth - this.scrollLeft, 'right', 'borderLeft');
@@ -295,6 +316,7 @@ var setFixedColumn = function () {
295
316
  css(tfoot, { left: this.scrollLeft });
296
317
  }
297
318
  };
319
+ var setLazyFixedColumn = lazy(setFixedColumn, 0);
298
320
  var setClass = function (tds, cls, old) {
299
321
  tds.forEach(td => td[cls] = true);
300
322
  old.forEach(td => { if (!td[cls]) removeClass(td, cls) });
@@ -348,7 +370,31 @@ var getTdsOfSameRow = function (td) {
348
370
  }
349
371
  return tds;
350
372
  };
351
-
373
+ function setContextMenu(thead) {
374
+ var fields = this.fields.slice();
375
+ var scope = this;
376
+ var menuItems = fields.map(f => {
377
+ return {
378
+ name: f.name || "&nbsp;",
379
+ checked: !f.hidden,
380
+ width: f.width,
381
+ do() {
382
+ this.checked = !this.checked;
383
+ f.hidden = !this.checked;
384
+ scope.fields = fields.filter(f => !f.hidden);
385
+ var width = thead.scrollWidth / scope.fields.length;
386
+ if (!width || width < 200) width = 200;
387
+ forEachRow(thead, function (tr) {
388
+ for (var td of tr.children) {
389
+ if (td.offsetWidth > width) css(td, { width });
390
+ }
391
+ });
392
+ setLazyFixedColumn.call(thead.parentNode, true)
393
+ }
394
+ }
395
+ });
396
+ contextmenu(thead, menuItems);
397
+ }
352
398
  function table(elem) {
353
399
  var tableElement = isElement(elem) ? elem : document.createElement("table");
354
400
  var activeCols = [];
@@ -378,7 +424,7 @@ function table(elem) {
378
424
  thead = getThead(table);
379
425
  }
380
426
  if (!getTargetIn(thead, event.target)) return;
381
- var tds = getTargetIn(cellMatchManager, event.target);
427
+ var tds = cellMatchManager(event.target);
382
428
  if (!tds) return;
383
429
  setClass(tds, 'y-ing', activeCols);
384
430
  removeXIng(activeRows);
@@ -408,12 +454,16 @@ function table(elem) {
408
454
  var { colstart, colend } = element;
409
455
  return getTdsByCol(table, colstart, colend);
410
456
  };
411
-
457
+ watch(table, {
458
+ showTotal(v) {
459
+ this.$scope.showTotal = v;
460
+ if (v) this.$scope.hasFoot = true;
461
+ }
462
+ })
412
463
  table.useIncrease = false;
413
464
  var _vbox = function () {
414
465
  table.$Left = function (x) {
415
- if (isFinite(x)) this.scrollLeft = x;
416
- setFixedColumn.call(this);
466
+ if (isFinite(x)) this.scrollLeft = x, setFixedColumn.call(this);
417
467
  return this.scrollLeft;
418
468
  };
419
469
  vbox(table, 'x');
@@ -435,10 +485,15 @@ function table(elem) {
435
485
  var $scope = {
436
486
  fields,
437
487
  isEmpty,
488
+ hasFoot: true,
489
+ setContextMenu,
438
490
  tbody0: null,
491
+ rowClick(d, i, event) {
492
+ active(table, i, d, event.target);
493
+ },
439
494
  tbody(e) {
440
495
  var e = list.apply(null, arguments);
441
- css(e, tbodyHeight(e));
496
+ css(e, tbodyHeight(e, this.hasFoot));
442
497
  css(e, { width: this.adapter.offsetWidth, display: 'block' });
443
498
  this.tbody0 = e;
444
499
  return e;
@@ -522,9 +577,7 @@ function table(elem) {
522
577
  }
523
578
  markThead();
524
579
  markedRows = true;
525
- requestAnimationFrame(function () {
526
- setFixedColumn.call(table)
527
- })
580
+ setLazyFixedColumn.call(table);
528
581
  }
529
582
  );
530
583
  resizingList.set(table, setFixedColumn);
@@ -62,6 +62,10 @@ td {
62
62
  }
63
63
  }
64
64
 
65
+ [draggable="false"]:before {
66
+ display: none;
67
+ }
68
+
65
69
  thead {
66
70
 
67
71
  .y-ing,
@@ -102,11 +106,14 @@ thead {
102
106
  border-right: 1px solid transparent;
103
107
  }
104
108
 
109
+ .fade {
110
+ color: #bbb;
111
+ }
112
+
105
113
  >tfoot {
106
114
  width: 100%;
107
115
  display: block;
108
116
  position: relative;
109
- color: #bbb;
110
117
 
111
118
  >tr {
112
119
  width: 100%;
@@ -27,7 +27,7 @@ function titlebar(elem) {
27
27
  }
28
28
  use_back = use_back !== false;
29
29
  var bar = nav.cloneNode();
30
- var title = label();
30
+ var title = document.createElement("label");
31
31
  var _back = back();
32
32
  text(title, page_title || document.title);
33
33
  appendChild(bar, title);
@@ -91,12 +91,12 @@ function ybox(generator) {
91
91
  };
92
92
  var stop = _box.$stopY || _box.stopY;
93
93
  var stop2 = lazy(function () {
94
- scrollY.smooth(stop);
94
+ scrollY.smooth(stop, 4);
95
95
  }, 40);
96
96
  var decrease = function (t) {
97
97
  var res = _decrease(increaser_t, t) + _decrease(increaser_b, t);
98
98
  if (!res) {
99
- scrollY.smooth(stop);
99
+ scrollY.smooth(stop, 4);
100
100
  }
101
101
  return true;
102
102
  };
package/docs/index.html CHANGED
@@ -10,6 +10,14 @@
10
10
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
11
11
  <link rel="Shortcut Icon" href="favicon.ico" type="image/x-icon" />
12
12
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,width=device-width" />
13
+ <script>
14
+ if (/Trident/i.test(navigator.userAgent)) document.createElement = function (createElement) {
15
+ return function (a) {
16
+ if (/\W/.test(a)) return createElement.call(this, 'efront');
17
+ return createElement.call(this, a);
18
+ };
19
+ }(document.createElement);
20
+ </script>
13
21
  <title>efront 文档</title>
14
22
  <style>
15
23
  body,
@@ -18,6 +26,7 @@
18
26
  margin: 0;
19
27
  overflow: hidden;
20
28
  }
29
+
21
30
  *,
22
31
  ::before,
23
32
  ::after {
package/docs/main.xht CHANGED
@@ -91,9 +91,13 @@
91
91
  closed: true,
92
92
  children: []
93
93
  },
94
- // {
95
- // name: "小工具"
96
- // }
94
+ {
95
+ name: "小工具",
96
+ closed: true,
97
+ children: [
98
+ "字符集检查"
99
+ ].map(a => ({ name: a, path: "/工具/" + a }))
100
+ }
97
101
  ];
98
102
  zimoli.register("/mark");
99
103
  zimoli.register("/命令");
@@ -0,0 +1,157 @@
1
+ <style>
2
+ h2 {
3
+ margin: 0;
4
+ padding: 10px 20px;
5
+ }
6
+
7
+ field {
8
+ width: 50%;
9
+ height: 200px;
10
+ display: inline-block;
11
+ position: relative;
12
+ vertical-align: top;
13
+ }
14
+
15
+ label {
16
+ padding: 0 20px;
17
+ }
18
+
19
+ .padding {
20
+ border: none;
21
+ padding: 0 20px;
22
+ width: 100%;
23
+ display: block;
24
+ }
25
+
26
+ [textarea] {
27
+ width: 100%;
28
+ height: 200px;
29
+ display: block;
30
+ border: 1.2px solid;
31
+ overflow-x: hidden;
32
+ overflow-y: scroll;
33
+ padding: 2px 6px;
34
+ }
35
+
36
+ [textarea]:focus {
37
+ border-color: #09c;
38
+ }
39
+
40
+ [textarea] w {
41
+ font-weight: normal;
42
+ color: #F24;
43
+ }
44
+
45
+ [textarea] a {
46
+ font-family: inherit;
47
+ font-weight: normal;
48
+ color: #08F;
49
+ }
50
+
51
+ button {
52
+ padding: 0 20px;
53
+ }
54
+ </style>
55
+ <h2>字符集检查工具</h2>
56
+ <div style="text-align: right;padding: 0 20px;">
57
+ <button @click="check">检查</button>
58
+ </div>
59
+ <div>
60
+ <field>
61
+ <label>要检查的字符集区间(unicode)</label>
62
+ <padding>
63
+ <div textarea contenteditable="true" -model="ranges"></div>
64
+ </padding>
65
+ </field>
66
+ <field>
67
+ <label>当前浏览器支持的字符集区间(unicode)</label>
68
+ <padding>
69
+ <div textarea contenteditable="true" -model="result"></div>
70
+ </padding>
71
+ </field>
72
+ </div>
73
+ <script>
74
+ var checkOne = function (one) {
75
+ if (!String.fromCodePoint && one > 0xffff) return '';
76
+ var s = (String.fromCodePoint || String.fromCharCode)(one);
77
+ try {
78
+ eval(`(function (${s}){})`);
79
+ return true;
80
+ }
81
+ catch (e) { }
82
+ return '';
83
+ };
84
+ var toHex = function (one) {
85
+ one = one.toString(16).toUpperCase();
86
+ if (one.length <= 2) {
87
+ return "\\x" + Array(3 - one.length).join("0") + one.toString(16);
88
+ }
89
+ else if (one.length <= 4) {
90
+ return "\\u" + Array(5 - one.length).join("0") + one;
91
+ }
92
+ return `\\u{${one}}`;
93
+ };
94
+ var fromHex = function (hex) {
95
+ var str = hex.replace(/^[xu]/, '').replace(/^\{([\s\S]+)\}$/, '$1');
96
+ return parseInt(str, 16);
97
+ }
98
+ var check = async function () {
99
+ var elem = alert("正在检查", false);
100
+ var reg = /\\(x[0-9a-f]{2}|u[0-9a-f]{4}|u\{[0-9a-f]+\})/ig;
101
+ var dist0 = [];
102
+ ranges.replace(/<\/?\w+\/?>/g, '').replace(new RegExp(`${reg.source}(?:-${reg.source})?|${/[\s\S]/.source}`, 'ig'), function (_, a, b) {
103
+ dist0.push([_, a, b]);
104
+ return _;
105
+ });
106
+ var dist = [];
107
+ var dist1 = dist0.slice();
108
+ while (dist0.length) {
109
+ var [_, a, b] = dist0.shift();
110
+ if (_.length === 1) {
111
+ if (checkOne(_.codePointAt(0))) dist.push(toHex(_.codePointAt(0)));
112
+ else dist.push('');
113
+ continue;
114
+ }
115
+ a = fromHex(a);
116
+ if (!b) {
117
+ if (checkOne(a)) dist.push(toHex(a));
118
+ else dist.push('');
119
+ continue;
120
+ }
121
+ b = fromHex(b);
122
+ elem.setText(`正在检查${_}`);
123
+ await new Promise(a => setTimeout(a, 20));
124
+ var start = a;
125
+ var temp = [];
126
+ while (a <= b) {
127
+ if (checkOne(a++)) continue;
128
+ var end = a - 2;
129
+ if (start === end) {
130
+ temp.push(toHex(start));
131
+ }
132
+ else if (start < end) {
133
+ temp.push([start, end].map(toHex).join("-"));
134
+ }
135
+ start = a;
136
+ }
137
+ if (start < b) {
138
+ temp.push([start, b].map(toHex).join("-"));
139
+ }
140
+ else if (start === b) {
141
+ temp.push(toHex(start));
142
+ }
143
+ dist.push(temp.join(''))
144
+ }
145
+ dist = dist.map((a, i) => {
146
+ if (a.toUpperCase() === dist1[i][0].toUpperCase()) return a;
147
+ dist1[i][0] = `<a>${dist1[i][0]}</a>`;
148
+ return `<w>${a}</w>`;
149
+ })
150
+ elem.setText("检查完成", 600);
151
+ ranges = dist1.map(a => a[0]).join("");
152
+ result = dist.join("");
153
+ }
154
+ var ranges = /\xAA\xB5\xBA\xC0-\xD5\xD8-\xF2\xF8-\u02af\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052f\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA/.source
155
+ var result = '';
156
+
157
+ </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.35.2",
3
+ "version": "3.35.4",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {