efront 4.5.15 → 4.5.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/coms/zimoli/on.js CHANGED
@@ -278,7 +278,6 @@ var remove = function (k, hk, [eventtypes, handler, context]) {
278
278
  var broadcast = function (k, hk, event) {
279
279
  var element = this;
280
280
  var handlers = element[hk];
281
- if (!handlers) console.log(handlers, hk, event, element)
282
281
  if (handlers.length > 1) handlers = handlers.slice();
283
282
  if (event.which === 1 && event.buttons === 0) {
284
283
  // firefox 无按键
@@ -426,7 +425,7 @@ var invoke = function (event, type, pointerType) {
426
425
 
427
426
  (function () {
428
427
  var pointeractive = null;
429
- if ("onpointerdown" in document || document.efronton) return;
428
+ if ("onpointerdown" in document) return;
430
429
  var getPointerType = function (event) {
431
430
  return event.type.replace(/(start|move|end|cancel|down|up|leave|out|over|enter)$/i, '');
432
431
  };
@@ -455,8 +454,7 @@ var invoke = function (event, type, pointerType) {
455
454
  }());
456
455
 
457
456
  (function () {
458
- // fastclick
459
- if (window.fastclick) return;
457
+ // 不再兼容fastclick
460
458
  var onclick = on("click");
461
459
  var onmousedown = on("mousedown");
462
460
  var onmousemove = on("mousemove");
@@ -471,13 +469,15 @@ var invoke = function (event, type, pointerType) {
471
469
  onclick.preventClick = false;
472
470
  pointerX = event.clientX, pointerY = event.clientY;
473
471
  }
474
- var abs = Math.abs;
472
+ var dis = (a, b) => a * a + b * b
475
473
  function clickcancel(event) {
476
- if (!event || abs(event.clientX - pointerX) >= MOVELOCK_DELTA || abs(event.clientY - pointerY) >= MOVELOCK_DELTA) onclick.preventClick = true;
474
+ if (!event || event.which && dis(event.clientX - pointerX, event.clientY - pointerY) >= MOVELOCK_DELTA * MOVELOCK_DELTA) {
475
+ onclick.preventClick = true;
476
+ }
477
477
  }
478
- onmousedown(window, clickstart);
478
+ onmousedown(window, clickstart, true);
479
479
 
480
- onmousemove(window, clickcancel);
480
+ onmousemove(window, clickcancel, true);
481
481
  if (window.addEventListener) {
482
482
  window.addEventListener("touchmove", function (event) {
483
483
  extendTouchEvent(event);
@@ -1,7 +1,7 @@
1
1
  <thead @mounted="setFixedColumn.call(this.parentNode),setContextMenu(this)">
2
2
  <tr inline-block #adapter thead @mounted="resizeT(this)">
3
- <td draggable="false" fixed row-index>${i18n`序号`}</td>
4
- <td fixed:="f.fixed" -repeat="f in fields track by f.id" :style="{width:f.width}" @dblclick="sort(f)"><i
3
+ <td draggable="false" fixed row-index><mask></mask>${i18n`序号`}</td>
4
+ <td fixed:="f.fixed" -repeat="f in fields track by f.id" :style="{width:f.width}" @dblclick="sort(f)" swapped_="f.summary"><mask></mask><i
5
5
  -if="f.icon" -class="f.icon"></i><span -if="f.name" -html="f.name"
6
6
  type@="typeof f.type==='string'?f.type:''"></span><template -else>&nbsp;</template>
7
7
  </td>
@@ -10,9 +10,10 @@
10
10
  </thead>
11
11
  <tbody -src="(d,i) in data" :style="tbodyHeight(this,hasFoot)">
12
12
  <tr inline-block :style="{width:adapter.style.width}" @click="rowClick(d,i,event)" @mounted="resizeR(this)">
13
- <td fixed row-index -bind="i+1" :style="adapter.firstChild.getAttribute('style')">
13
+ <td fixed row-index :style="adapter.firstChild.getAttribute('style')"><mask></mask><span -bind="i+1"></span>
14
14
  </td>
15
15
  <td fixed:="f.fixed" -repeat="(f,i) in fields" :style="adapter.children[i+1].getAttribute('style')">
16
+ <mask></mask>
16
17
  <model -if="!isEmpty(f.key)" :field=f :data=d readonly></model>
17
18
  <template -else>&nbsp;</template>
18
19
  <a on-click="o.do(d)" -if="isEmpty(f.key)&&f.options&&(!o.when||o.when(d))"
@@ -20,7 +21,7 @@
20
21
  <span -text="o.name instanceof Function?o.name(d):o.name"></span>
21
22
  </a>
22
23
  </td>
23
- <td :style="adapter.lastChild.getAttribute('style')">&nbsp;</td>
24
+ <td :style="adapter.lastChild.getAttribute('style')"><mask></mask>&nbsp;</td>
24
25
  </tr>
25
26
  </tbody>
26
27
  <tfoot>
@@ -161,6 +161,7 @@ var resizeColumn = function (target, targetW) {
161
161
  }
162
162
  };
163
163
  var resizeTarget = function (event) {
164
+ if (swapping && onclick.preventClick) swapping.end(), swapping = null;
164
165
  var { resizing } = this;
165
166
  if (!resizing) return;
166
167
  event.moveLocked = true;
@@ -406,15 +407,34 @@ function setContextMenu(thead) {
406
407
  var scope = this;
407
408
  contextmenu(thead, menuItems);
408
409
  }
410
+
411
+ var swapping = null;
412
+
409
413
  function table(elem) {
410
414
  var tableElement = isElement(elem) ? elem : document.createElement("table");
411
415
  var activeCols = [];
412
416
  bind('mousemove')(tableElement, adaptTarget);
417
+ var updateSummaryFields = null;
413
418
  moveupon(tableElement, {
414
419
  start(event) {
415
- if (this.resizing) event.preventDefault();
420
+ if (this.resizing) return event.preventDefault();
421
+ if (!updateSummaryFields) return;
422
+ var thead = getThead(this);
423
+ var th = getTargetIn(thead, event.target, false);
424
+ if (!th) return;
425
+ if (th.tagName.toLowerCase() === 'tr') th = getTargetIn(th, event.target, false);
426
+ var field = th.$scope?.f;
427
+ if (!field || field.fixed || !isHandled(field.key)) return;
428
+ swapping = lazySwap(th, function (value) {
429
+ field.summary = value;
430
+ updateSummaryFields();
431
+ });
432
+ swapping.start();
416
433
  },
417
434
  move: resizeTarget,
435
+ end() {
436
+ if (swapping) swapping.end(), swapping = null;
437
+ }
418
438
  });
419
439
  var activeRows = [];
420
440
  onmousemove(tableElement, function (event) {
@@ -436,6 +456,7 @@ function table(elem) {
436
456
  }
437
457
  if (!getTargetIn(thead, event.target)) return;
438
458
  var tds = cellMatchManager(event.target);
459
+
439
460
  if (!tds) return;
440
461
  setClass(tds, 'y-ing', activeCols);
441
462
  removeXIng(activeRows);
@@ -456,13 +477,15 @@ function table(elem) {
456
477
  };
457
478
  var cellMatchManager = function (element) {
458
479
  if (!thead) thead = getThead(table);
459
- if (!getTargetIn(thead, element)) return false;
460
- if (!tdElementReg.test(element.tagName)) return false;
480
+ var td = getTargetIn(thead, element, false);
481
+ if (!td) return false;
482
+ if (td.tagName.toLowerCase() === 'tr') td = getTargetIn(td, element, false);
483
+ if (!tdElementReg.test(td.tagName)) return false;
461
484
  if (!markedRows) {
462
485
  markThead();
463
486
  markedRows = true;
464
487
  }
465
- var { colstart, colend } = element;
488
+ var { colstart, colend } = td;
466
489
  return getTdsByCol(table, colstart, colend);
467
490
  };
468
491
  watch(table, {
@@ -497,6 +520,10 @@ function table(elem) {
497
520
  }
498
521
  }
499
522
  })
523
+ updateSummaryFields = function () {
524
+ $scope.data.summaryFields = fields.filter(f => f.summary);
525
+ $scope.data.update();
526
+ };
500
527
  thead = null;
501
528
  fields.forEach(enrichField);
502
529
  remove(this.children);
@@ -43,12 +43,15 @@ td {
43
43
  white-space: normal;
44
44
  height: 100%;
45
45
  padding: 2px 10px;
46
+
47
+ >* {
48
+ position: relative;
49
+ }
46
50
  }
47
51
 
48
52
  .y-ing,
49
53
  .x-ing {
50
- &:before {
51
- content: "";
54
+ >mask {
52
55
  position: absolute;
53
56
  left: 0;
54
57
  top: 0;
@@ -57,13 +60,9 @@ td {
57
60
  pointer-events: none;
58
61
  background-color: rgba(0, 60, 69, .06);
59
62
  }
60
-
61
- >* {
62
- position: relative;
63
- }
64
63
  }
65
64
 
66
- [draggable="false"]:before {
65
+ [draggable="false"]>mask {
67
66
  display: none;
68
67
  }
69
68
 
@@ -71,7 +70,7 @@ thead {
71
70
 
72
71
  .y-ing,
73
72
  .x-ing {
74
- &:before {
73
+ >mask {
75
74
  background-color: rgba(0, 60, 69, .3);
76
75
  }
77
76
  }
@@ -144,8 +143,27 @@ thead {
144
143
  color: #fff;
145
144
  background-color: #395268;
146
145
  clear: both;
146
+
147
+ &:before {
148
+ content: '';
149
+ display: block;
150
+ position: absolute;
151
+ left: 0;
152
+ height: 0;
153
+ bottom: 0;
154
+ right: 0;
155
+ background: #426;
156
+ transition: height .3s ease-in;
157
+ transition-delay: .7s;
158
+ }
159
+
160
+ &[swapped]:before {
161
+ height: 100%;
162
+ }
147
163
  }
148
164
  }
165
+
166
+
149
167
  }
150
168
 
151
169
  >tbody {
@@ -61,11 +61,6 @@
61
61
  }
62
62
 
63
63
  }
64
-
65
- p span,
66
- p a {
67
- vertical-align: middle;
68
- }
69
64
  </style>
70
65
  <p><span>${i18n`翻译结果仅做为参考,未必完美替换,语法参考:`}<a @click="zimoli.go('/组件/basic/i18n.js',{mark:true})">i18n.js</a></span></p>
71
66
  <p -if="!window.showDirectoryPicker" error>${i18n`国际化工具仅在浏览器支持 showDirectoryPicker 时可用`}</p>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.5.15",
3
+ "version": "4.5.17",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {