efront 3.22.7 → 3.22.10

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.
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
- function parseKV(string, spliter = "&", equals = "=") {
2
+ var trim = a => a.trim();
3
+ function parseKV(string, spliter = "&", equals = "=", decode) {
3
4
  var object = {};
4
- var decode = spliter === "&" && equals === "=" ? decodeURIComponent : a => a;
5
+ if (!decode) decode = spliter === "&" && equals === "=" ? decodeURIComponent : trim;
5
6
  if (typeof string === "string") {
6
7
  var kvs = string.split(spliter);
7
8
  for (var cx = 0, dx = kvs.length; cx < dx; cx++) {
@@ -28,7 +28,7 @@ var $scope = {
28
28
  function main() {
29
29
  var page = view();
30
30
  page.initialStyle = 'margin-top:10px;opacity:0';
31
- page.setAttribute("_dragable", "false");
31
+ page.setAttribute("_draggable", "false");
32
32
  page.innerHTML = playList;
33
33
  $scope.play = function (i) {
34
34
  if (page.play instanceof Function) {
@@ -7,28 +7,7 @@ var dragview = function (dragview) {
7
7
  savedX = event.clientX;
8
8
  savedY = event.clientY;
9
9
  offsetWidth = menu.offsetWidth;
10
- var { target } = event;
11
10
  moving = null;
12
- if (/(input|textarea|select)/i.test(target.tagName) || getTargetIn(a => a.nodrag || a.hasAttribute('nodrag') || a.dragable === false, event.target)) {
13
- moving = false;
14
- } else {
15
- var { childNodes } = target;
16
- if (getComputedStyle(target).cursor === 'auto' && getComputedStyle(target).userSelect !== 'none') for (var cx = 0, dx = childNodes.length; cx < dx; cx++) {
17
- var child = childNodes[cx];
18
- if (child.nodeType === 3) {
19
- moving = false;
20
- break;
21
- }
22
- }
23
- if (moving !== false) do {
24
- var contentEditbale = target.getAttribute("contenteditable") !== null;
25
- if (contentEditbale) {
26
- moving = false;
27
- break;
28
- }
29
- target = target.parentNode;
30
- } while (target && target.nodeType == 1);
31
- }
32
11
  },
33
12
  move(event) {
34
13
  if (moving === false) return;
@@ -25,9 +25,11 @@ var moveChildrenX = function (targetBox, previousElements, followedElements, mov
25
25
  var elementPosition = getScreenPosition(element);
26
26
  var elementCenter = elementPosition.left + elementPosition.width / 2;
27
27
  var delta = elementCenter - (element.moved || 0);
28
- if (delta + 2 <= dragPositionLeft) {
28
+ if ((!element.hasAttribute || element.hasAttribute('draggable')) && element.draggable === false);
29
+ else if (delta + 2 <= dragPositionLeft) {
29
30
  recover(element);
30
- } else if (delta - 2 >= dragPositionLeft) {
31
+ }
32
+ else if (delta - 2 >= dragPositionLeft) {
31
33
  moveMargin(element, dragPosition.width);
32
34
  }
33
35
  });
@@ -35,9 +37,11 @@ var moveChildrenX = function (targetBox, previousElements, followedElements, mov
35
37
  var elementPosition = getScreenPosition(element);
36
38
  var elementCenter = elementPosition.left + elementPosition.width / 2;
37
39
  var delta = elementCenter - (element.moved || 0);
38
- if (delta + 2 <= dragPositionRight) {
40
+ if ((!element.hasAttribute || element.hasAttribute('draggable')) && element.draggable === false);
41
+ else if (delta + 2 <= dragPositionRight) {
39
42
  moveMargin(element, -dragPosition.width);
40
- } else if (delta - 2 >= dragPositionRight) {
43
+ }
44
+ else if (delta - 2 >= dragPositionRight) {
41
45
  recover(element);
42
46
  }
43
47
  });
@@ -53,6 +57,10 @@ var moveChildrenX = function (targetBox, previousElements, followedElements, mov
53
57
  var scrollX = function (targetBox, moveChildren) {
54
58
  var dragTarget = drag.target;
55
59
  if (!dragTarget || !targetBox) return;
60
+ targetBox = getTargetIn(function (a) {
61
+ var computed = getComputedStyle(a);
62
+ return (computed.overflowX || computed.overflow) !== 'visible' && a.scrollWidth > a.clientWidth;
63
+ }, targetBox);
56
64
  var areaPosition = getScreenPosition(targetBox);
57
65
  var dragPosition = getScreenPosition(dragTarget);
58
66
  var scrollDelta = 0;
@@ -133,7 +141,8 @@ var hooka = function (matcher, move, event, targetChild, isMovingSource) {
133
141
  var [target] = targets;
134
142
  return {
135
143
  style: target.style, target, getBoundingClientRect,
136
- with: targets
144
+ with: targets,
145
+ draggable: !target.hasAttribute('draggable') || target.draggable,
137
146
  };
138
147
  }
139
148
  return targets;
@@ -227,7 +236,6 @@ var hooka = function (matcher, move, event, targetChild, isMovingSource) {
227
236
  var children = targetBox.children;
228
237
  var srcElement = children[src];
229
238
  var dstElement = children[dst + delta];
230
- console.log(targetChild, src)
231
239
  src = bindTarget(src, isMovingSource ? targetChild : srcElement);
232
240
  dst = bindTarget(dst, dstElement);
233
241
  var needFire = !isFunction(move) || move(src, dst, dst + delta, appendSibling, targetBox) !== false;
@@ -249,7 +257,8 @@ var hooka = function (matcher, move, event, targetChild, isMovingSource) {
249
257
  var autoScroll = function () {
250
258
  if (autoScroll.ing) return;
251
259
  if (scroll) autoScroll.ing = setInterval(function () {
252
- var delta = scroll(targetBox, moveChildren);
260
+ var delta = scroll(targetBox, dragmove);
261
+ if (isFunction(matcher)) return;
253
262
  if (isMovingSource === false) { }
254
263
  else if (delta < 0) {
255
264
  var p = null;
@@ -34,14 +34,14 @@ var setZIndex = function () {
34
34
  };
35
35
  function drag(target, initialEvent, preventOverflow, isMovingSource) {
36
36
  if (/^(?:select|input|textarea)$/i.test(initialEvent.target.tagName) || getTargetIn(a => a.nodrag || a.hasAttribute('nodrag'), initialEvent.target)) return;
37
- if (target.dragable === false) return;
38
- initialEvent.preventDefault();
39
37
  if (isArray(target)) {
40
38
  var extraTargets = target.slice(1);
41
39
  target = target[0];
42
40
  } else {
43
41
  var extraTargets = target.with ? [].concat(target.with) : [];
44
42
  }
43
+ if ((!target.hasAttribute || target.hasAttribute('draggable')) && target.draggable === false) return;
44
+ initialEvent.preventDefault();
45
45
  var target_offset = getOffset(target);
46
46
  var saved_delta = { x: target_offset[0] - initialEvent.screenX, y: target_offset[1] - initialEvent.screenY };
47
47
  var clone;
@@ -1,17 +1,28 @@
1
1
  var _input = createElement("input");
2
+ /**
3
+ * @this HTMLInputElement
4
+ */
2
5
  var number = function (event) {
3
6
  var ipt = event.target;
4
7
  var { keyCode } = event;
5
8
  var { value, type } = ipt;
9
+ var s = this.selectionStart;
6
10
  if (keyCode === 13 || keyCode === 18 || keyCode === 37 || keyCode === 38 || keyCode === 39 || keyCode === 40 || keyCode === 8 || keyCode === 46 || keyCode === 9) {
7
11
  }
8
12
  else if (keyCode >= 48 && keyCode <= 57 || keyCode >= 96 && keyCode <= 105) {
9
13
  if (this.value) {
10
- if (this.fixed && this.value.replace(/^[^\.]+/, '').length > this.fixed ||
14
+ if (s < this.value.length) {
15
+ var index = this.value.indexOf('.');
16
+ if (index >= 0 && s > index) {
17
+ this.value = this.value.slice(0, this.value.length - 1);
18
+ }
19
+ this.setSelectionRange(s, s);
20
+ }
21
+ else if (this.fixed && this.value.replace(/^[^\.]+/, '').length > this.fixed ||
11
22
  this.limit && this.value.length >= this.limit && !/\./.test(this.value)) {
12
23
  event.preventDefault();
13
24
  }
14
- if(/^[+-]?0$/.test(this.value)){
25
+ else if (/^[+-]?0$/.test(this.value)) {
15
26
  event.preventDefault();
16
27
  }
17
28
  }
@@ -19,14 +30,27 @@ var number = function (event) {
19
30
  else if (keyCode === 110 || keyCode === 190) {
20
31
  if (/^int/i.test(type)) {
21
32
  event.preventDefault();
22
- } else if (/\./i.test(value) || !value || /^[\-\+]$/.test(value)) {
33
+ }
34
+ else if (/\./i.test(value)) {
35
+ var index = this.value.indexOf(".");
36
+ if (s < index) {
37
+ this.value = this.value.slice(0, s) + this.value.slice(index + 1);
38
+ this.setSelectionRange(s, s);
39
+ }
40
+ else {
41
+ event.preventDefault();
42
+ }
43
+ }
44
+ else if (!value || /^[\-\+]$/.test(value)) {
23
45
  event.preventDefault();
24
46
  }
25
- } else if (keyCode === 189 || keyCode === 187) {// 负号 正号
47
+ }
48
+ else if (keyCode === 189 || keyCode === 187) {// 负号 正号
26
49
  if (value || this.positive) {
27
50
  event.preventDefault();
28
51
  }
29
- } else {
52
+ }
53
+ else {
30
54
  event.preventDefault();
31
55
  }
32
56
  if (value && !/^[\d]+$/i.test(value)) {
@@ -36,11 +60,19 @@ var number = function (event) {
36
60
  if (value !== v) {
37
61
  ipt.value = v;
38
62
  }
39
- } else if (!/^[\-\+]$/.test(value)) {
63
+ }
64
+ else if (!/^[\-\+]$/.test(value)) {
40
65
  ipt.value = '';
41
66
  }
42
67
  }
43
68
  };
69
+ var toFixed = function () {
70
+ if (this.value && this.fixed) var fixed = BigNumber.fix(this.value, this.fixed);
71
+ if (this.value !== fixed) {
72
+ this.value = fixed;
73
+ dispatch(this, 'change');
74
+ }
75
+ };
44
76
  var positiveReg = /^\+|^positive\-?|\-?positive$|\+$/i;
45
77
  var negativeReg = /^\-|^negative\-?|\-?negative$|\-$/i;
46
78
  var numberLimit = /\:(\d+)?(?:\.(\d+))?$/;
@@ -92,6 +124,7 @@ function input(element) {
92
124
  case "money":
93
125
  if (!element.fixed) element.fixed = 2;
94
126
  on("keydown")(element, number);
127
+ on("blur")(element, toFixed);
95
128
  break;
96
129
  case "natural":
97
130
  if (!+element.positive) element.positive = true;
@@ -23,6 +23,30 @@ function removeAllListeners() {
23
23
  if (isFunction(offhook)) offhook();
24
24
  offhook = null;
25
25
  }
26
+ if (/Firefox/.test(navigator.userAgent)) on('dragstart')(document, function (e) {
27
+ if (e.target.draggable === false) {
28
+ e.preventDefault();
29
+ return false;
30
+ }
31
+ });
32
+ var locktouch = function (target) {
33
+ if (/(input|textarea|select)/i.test(target.tagName) || getTargetIn(a => String(a.contentEditable) === 'true' || a.draggable, target)) {
34
+ return true;
35
+ } else {
36
+ var { childNodes } = target;
37
+ var a = getTargetIn(a => {
38
+ if ((getComputedStyle(a).userSelect || getComputedStyle(a).webkitUserSelect) !== 'auto') return a;
39
+ });
40
+ if (!a) return;
41
+ var computed = getComputedStyle(a);
42
+ if (computed.cursor === 'auto' && (computed.userSelect || computed.webkitUserSelect) !== 'none') for (var cx = 0, dx = childNodes.length; cx < dx; cx++) {
43
+ var child = childNodes[cx];
44
+ if (child.nodeType === 3) {
45
+ return true;
46
+ }
47
+ }
48
+ }
49
+ };
26
50
 
27
51
  function moveupon(target, { start, move, end }, initialEvent) {
28
52
  var touchLocked = false;
@@ -47,20 +71,18 @@ function moveupon(target, { start, move, end }, initialEvent) {
47
71
  if (isFunction(end)) end.call(target, event);
48
72
  };
49
73
  var hookmouse = function () {
50
- if (touchLocked) return;
51
- touchLocked = true;
52
74
  addHookListener(onmousemove, mousemove, target === window);
53
75
  offmouseup = onmouseup(window, cancel);
54
76
  };
55
77
  var hooktouch = function () {
56
- if (touchLocked) return;
57
- touchLocked = true;
58
78
  addHookListener(ontouchmove, touchmove, target === window);
59
79
  offtouchend = ontouchend(target, cancel);
60
80
  offtouchcancel = ontouchcancel(target, cancel);
61
81
  };
82
+
62
83
  if (!start) {
63
84
  if (!initialEvent) throw new Error("请传入touchstartEvent或者mousedownEvent");
85
+ if (locktouch(initialEvent.target)) return;
64
86
  if (initialEvent.type === "touchstart") {
65
87
  extendTouchEvent(initialEvent);
66
88
  initialEvent.preventDefault();
@@ -71,10 +93,16 @@ function moveupon(target, { start, move, end }, initialEvent) {
71
93
  return;
72
94
  }
73
95
  onmousedown(target, function (event) {
96
+ if (touchLocked) return;
97
+ if (locktouch(event.target)) return;
98
+ touchLocked = true;
74
99
  hookmouse(event);
75
100
  if (isFunction(start)) start.call(this, event);
76
101
  });
77
102
  ontouchstart(target, function (event) {
103
+ if (touchLocked) return;
104
+ if (locktouch(event.target)) return;
105
+ touchLocked = true;
78
106
  extendTouchEvent(event);
79
107
  hooktouch(event);
80
108
  if (isFunction(start)) start.call(this, event);
@@ -1,6 +1,6 @@
1
1
  <thead @mounted="setFixedColumn.call(this.parentNode)">
2
2
  <tr inline-block #adapter thead @mounted="resizeT(this)">
3
- <td fixed row-index>序号</td>
3
+ <td draggable="false" fixed row-index>序号</td>
4
4
  <td fixed:="f.fixed" -repeat="f in fields track by f.id" :style="{width:f.width}" @dblclick="sort(f)"><i
5
5
  -if="f.icon" -class="f.icon"></i><span -if="f.name" -html="f.name"></span><template
6
6
  -else>&nbsp;</template>
@@ -9,7 +9,7 @@
9
9
  </thead>
10
10
  <tbody -src="(d,i) in data" :style="tbodyHeight(this)">
11
11
  <tr inline-block @mounted="this.style.width=adapter.style.width">
12
- <td fixed row-index -bind="i+1" @mounted="this.style=adapter.firstChild.getAttribute('style')">
12
+ <td draggable="false" fixed row-index -bind="i+1" @mounted="this.style=adapter.firstChild.getAttribute('style')">
13
13
  </td>
14
14
  <td fixed:="f.fixed" -repeat="(f,i) in fields"
15
15
  @mounted="this.style=adapter.children[i+1].getAttribute('style')">
@@ -365,6 +365,7 @@ function table(elem) {
365
365
  }
366
366
  if (!getTargetIn(thead, event.target)) return;
367
367
  var tds = getTargetIn(cellMatchManager, event.target);
368
+ if (!tds) return;
368
369
  setClass(tds, 'y-ing', activeCols);
369
370
  activeCols = tds;
370
371
  });
@@ -379,15 +380,18 @@ function table(elem) {
379
380
  var table = tableElement;
380
381
  var thead;
381
382
  var markedRows = false;
383
+ var markThead = function () {
384
+ var savedRowDeltas = [];
385
+ Array.prototype.forEach.call(thead.children, function (tr) {
386
+ markRowTds(tr, savedRowDeltas);
387
+ });
388
+ };
382
389
  var cellMatchManager = function (element) {
383
390
  if (!thead) thead = getThead(table);
384
391
  if (!getTargetIn(thead, element)) return false;
385
392
  if (!tdElementReg.test(element.tagName)) return false;
386
393
  if (!markedRows) {
387
- var savedRowDeltas = [];
388
- Array.prototype.forEach.call(thead.children, function (tr) {
389
- markRowTds(tr, savedRowDeltas);
390
- });
394
+ markThead();
391
395
  markedRows = true;
392
396
  }
393
397
  var { colstart, colend } = element;
@@ -468,14 +472,17 @@ function table(elem) {
468
472
  var dstElement = children[rel];
469
473
  var dstTds = getRowsOfTdsByCol(table, dstElement.colstart, dstElement.colend);
470
474
  var srcTds = getRowsOfTdsByCol(table, srcElement.colstart, srcElement.colend);
475
+ var clearCss = { left: '', right: '', borderLeft: '', borderRight: '' };
471
476
  if (append === appendChild.before) {
472
477
  srcTds.map(function (src, cx) {
473
478
  var dst = dstTds[cx];
474
479
  var d = dst[0] || dst.next;
475
480
  if (d) src.map(function (s) {
481
+ css(s, clearCss);
476
482
  append(d, s);
477
483
  });
478
484
  else if (d = dst.prev) src.map(function (s) {
485
+ css(s, clearCss);
479
486
  appendChild.after(d, s);
480
487
  d = s;
481
488
  });
@@ -485,15 +492,22 @@ function table(elem) {
485
492
  var dst = dstTds[cx];
486
493
  var d = dst[dst.length - 1] || dst.prev;
487
494
  if (d) src.map(function (s) {
495
+ css(s, clearCss);
488
496
  append(d, s);
489
497
  d = s;
490
498
  });
491
499
  else if (d = dst.next) src.map(function (s) {
500
+ css(s, clearCss);
492
501
  appendChild.before(d, s);
493
502
  });
494
503
  });
495
504
 
496
505
  }
506
+ markThead();
507
+ markedRows = true;
508
+ requestAnimationFrame(function(){
509
+ setFixedColumn.call(table)
510
+ })
497
511
  }
498
512
  );
499
513
  resizingList.set(table);
@@ -1,6 +1,5 @@
1
1
 
2
2
  var prototype = {
3
- dragable: undefined,
4
3
  resizable: false,
5
4
  closeable: true,
6
5
  showTitle: true,
@@ -98,10 +97,10 @@ function view(element) {
98
97
  if (window !== element) {
99
98
  extend(window, element);
100
99
  once("append")(window, function () {
101
- if (window.dragable !== true && window.dragable !== false) {
102
- window.dragable = /^(fixed|absolute)$/i.test(getComputedStyle(window).position);
100
+ if (window.draggable !== true && window.draggable !== false) {
101
+ window.draggable = /^(fixed|absolute)$/i.test(getComputedStyle(window).position);
103
102
  }
104
- if (window.dragable) window.setAttribute('dragable', 'dragable');
103
+ if (window.draggable) window.setAttribute('draggable', 'draggable');
105
104
  })
106
105
  if (window.resizable) resize.on(window);
107
106
  }
@@ -16,7 +16,7 @@ body>& {
16
16
  border: 1px solid #0006;
17
17
  }
18
18
 
19
- &[dragable] {
19
+ &[draggable] {
20
20
  position: absolute;
21
21
  }
22
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.22.7",
3
+ "version": "3.22.10",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {