efront 3.22.6 → 3.22.9

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.
@@ -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) {
@@ -9,7 +9,7 @@ var dragview = function (dragview) {
9
9
  offsetWidth = menu.offsetWidth;
10
10
  var { target } = event;
11
11
  moving = null;
12
- if (/(input|textarea|select)/i.test(target.tagName) || getTargetIn(a => a.nodrag || a.hasAttribute('nodrag') || a.dragable === false, event.target)) {
12
+ if (/(input|textarea|select)/i.test(target.tagName) || getTargetIn(a => a.contentEditbale || a.draggable, event.target)) {
13
13
  moving = false;
14
14
  } else {
15
15
  var { childNodes } = target;
@@ -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;
@@ -282,12 +282,12 @@ function single(c, u) {
282
282
  return [r * u, g * u, b * u];
283
283
  }
284
284
  function angle(c1, c2) {
285
+ c1 = parse(c1);
286
+ c2 = parse(c2);
287
+ c1 = normal(c1);
288
+ c2 = normal(c2);
285
289
  var theta = rgb2h(c2[0], c2[1], c2[2]) - rgb2h(c1[0], c1[1], c1[2]);
286
290
  if (theta < 0) theta += 360;
287
- // c1 = parse(c1);
288
- // c2 = parse(c2);
289
- // c1 = normal(c1);
290
- // c2 = normal(c2);
291
291
  // var [r1, g1, b1] = single(c1);
292
292
  // var [r2, g2, b2] = single(c2);
293
293
  // var c = [g1 * b2 - g2 * b1, b1 * r2 - b2 * r1, r1 * g2 - r2 * g1];
@@ -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;
@@ -52,15 +52,17 @@ var power = function (source, search) {
52
52
  var match_text_pre = source.slice(0, match_start2);
53
53
  var match_text_aft = source.slice(match_start2 + match_text.length);
54
54
  var pp = 0, ap = 0;
55
+ var p = match_text.length;
56
+ if (match_text_pre.length) p += .1 / match_text_pre.length - .2;
57
+ if (match_text_aft.length) p += .1 / match_text_aft.length - .1;
55
58
  if (match_text_pre.length > 1) {
56
59
  [pp, match_text_pre] = power(match_text_pre, search);
57
60
  }
58
61
  if (match_text_aft.length > 1) {
59
62
  [ap, match_text_aft] = power(match_text_aft, search);
60
63
  }
61
- var p = match_text.length;
62
- p *= p;
63
- return [p + pp + ap, match_text_pre + MARK_PRE + match_text + MARK_AFT + match_text_aft];
64
+ p += (pp + ap) * .01;
65
+ return [p, match_text_pre + MARK_PRE + match_text + MARK_AFT + match_text_aft];
64
66
  }
65
67
  return [0, source];
66
68
  };
@@ -1,19 +1,77 @@
1
1
  function search(seartext, options, path = "name") {
2
- if (options instanceof Array) {
3
- var hasFullmatch = false;
4
- var a = options.map(o => {
5
- var name = seek(o, path);
6
- if (name === seartext) hasFullmatch = true;
7
- var [power, m] = mark.power(name, seartext);
8
- o = Object.create(o);
9
- o.power = power;
10
- if (path) o[path] = m;
11
- return o;
12
- }).filter(a => a.power > 0);
13
- a.sort(function (a, b) {
14
- return b.power - a.power;
15
- });
16
- a.hasFullmatch = hasFullmatch;
17
- return a;
2
+ var a = new SearchResult;
3
+ a.searchPath = path;
4
+ a.searchText = seartext;
5
+ a.source = options;
6
+ if (a.searchText) a.start();
7
+ return a;
8
+ }
9
+ function minusPower(a, b) {
10
+ return a.power - b.power >= 0;
11
+ }
12
+ function returnName() {
13
+ return this.name;
14
+ }
15
+ class SearchResult extends Array {
16
+ searchPath = 'name';
17
+ searchText = null;
18
+ source = null;
19
+ complete = true;
20
+ searched = 0;
21
+ searchid = 0;
22
+ hasFullmatch = false;
23
+ callback = null;
24
+ addItem(o) {
25
+ var path = this.searchPath;
26
+ var seartext = this.searchText;
27
+ if (isEmpty(o)) return;
28
+ var name = seek(o, path);
29
+ if (name === seartext) this.hasFullmatch = true;
30
+ var [power, m] = mark.power(name, seartext);
31
+ if (isNode(o)) {
32
+ o = extend({
33
+ name: o.name,
34
+ title: o.title,
35
+ value: o.value,
36
+ key: o.key,
37
+ nodeType: o.nodeType,
38
+ tagName: o.tagName,
39
+ nodeValue: o.nodeValue,
40
+ }, o);
41
+ }
42
+ else o = isObject(o) ? Object.create(o) : new o.constructor(o);
43
+ o.power = power;
44
+ if (isString(path)) o[path] = m;
45
+ else o.name = m, o.toString = returnName, o.valueOf = returnName;
46
+ if (o.power > 0) {
47
+ saveToOrderedArray(this, o, minusPower);
48
+ }
49
+ }
50
+ search(text, callback) {
51
+ if (isFunction(callback)) this.callback = callback;
52
+ if (text === this.searchText) return;
53
+ this.searchText = text;
54
+ this.start();
55
+ }
56
+ async start() {
57
+ this.searched = 0;
58
+ this.splice(0, this.length);
59
+ var searchid = ++this.searchid;
60
+ this.complete = false;
61
+ if (this.searchText) for (var o of this.source) {
62
+ this.addItem(o);
63
+ if (++this.searched % 6000 === 0) {
64
+ if (isFunction(this.callback)) this.callback();
65
+ await new Promise(function (ok) {
66
+ setTimeout(ok, 20)
67
+ });
68
+ if (this.searchid !== searchid) break;
69
+ }
70
+ }
71
+ this.complete = true;
72
+ if (isFunction(this.callback)) this.callback();
73
+ }
74
+ abort() {
75
+ this.searchid++;
18
76
  }
19
77
  }
@@ -124,7 +124,7 @@ function select(target, list, removeOnSelect, direction) {
124
124
  var initList2 = function (src) {
125
125
  src.forEach(s => {
126
126
  optionsMap[s.key] = s;
127
- s.selected = s.key === target.value;
127
+ if (isObject(s)) s.selected = s.key === target.value;
128
128
  });
129
129
  list = selectList(generator, src, !!target.multiple, !!target.editable);
130
130
  list.value = target.value;
@@ -183,6 +183,7 @@ function select(target, list, removeOnSelect, direction) {
183
183
  if (!target.multiple) {
184
184
  onclick(list, onlistclick);
185
185
  }
186
+ removeOnSelect = undefined;
186
187
  bindEvent();
187
188
  };
188
189
  }
@@ -2,7 +2,7 @@ var singleClick = function () {
2
2
  var node = this.parentNode;
3
3
  if (node.activeNode === this) return;
4
4
  if (node.activeNode) {
5
- if (node.activeNode.origin) node.activeNode.origin.selected = false;
5
+ if (isObject(node.activeNode.origin)) node.activeNode.origin.selected = false;
6
6
  node.activeNode.removeAttribute("selected");
7
7
  }
8
8
  this.setAttribute("selected", "");
@@ -11,8 +11,9 @@ var singleClick = function () {
11
11
  if (node.value === this.value) return;
12
12
  node.value = this.value;
13
13
  node.name = this.name;
14
- if (this.origin) this.origin.selected = true;
14
+ if (isObject(this.origin)) this.origin.selected = true;
15
15
  dispatch(node, "change");
16
+ if (getTargetIn(node, document.activeElement)) document.activeElement.blur();
16
17
  };
17
18
  var multipleClick = function () {
18
19
  var node = this.parentNode;
@@ -25,10 +26,15 @@ var multipleClick = function () {
25
26
  values.splice(index, 1);
26
27
  this.removeAttribute("selected");
27
28
  }
28
- if (this.origin) this.origin.selected = true;
29
+ if (isObject(this.origin)) this.origin.selected = true;
29
30
  dispatch(node, "change");
30
31
  };
31
32
 
33
+ var searchinput = function () {
34
+ var ipt = document.createElement("input");
35
+ ipt.placeholder = '搜索';
36
+ return ipt;
37
+ };
32
38
 
33
39
  function main() {
34
40
  var children, multiple, addable, generator, page;
@@ -101,9 +107,46 @@ function main() {
101
107
 
102
108
 
103
109
  var hasIcon = false, iconed = '';
110
+
111
+ if (children.length > 6) {
112
+ var ipt = searchinput()
113
+ page.insertBefore(ipt, page.firstChild);
114
+ var searchtext = function () {
115
+ if (this.value) children = searchResult;
116
+ else children = searchResult.source;
117
+ if (isMounted(this)) searchResult.search(this.value);
118
+ };
119
+ var searchResult = search(ipt.value, children, a => {
120
+ return isObject(a) ? getName(a) : String(a);
121
+ });
122
+ searchResult.callback = function () {
123
+ if (!searchResult.complete) {
124
+ page.setAttribute('searching', '');
125
+ }
126
+ else {
127
+ if (searchResult.searchText && !searchResult.length) {
128
+ page.setAttribute('empty', '');
129
+ }
130
+ else {
131
+ page.removeAttribute('empty');
132
+ }
133
+ page.removeAttribute('searching');
134
+ }
135
+ itemMap = Object.create(null);
136
+ page.clean();
137
+ page.go(0);
138
+ }
139
+ on('remove')(ipt, function () {
140
+ searchResult.abort();
141
+ });
142
+ on('input')(ipt, searchtext);
143
+ on('keyup')(ipt, searchtext);
144
+ on('change')(ipt, searchtext);
145
+
146
+ }
104
147
  var page = list(page, function (i) {
105
148
  if (i < 0 || i >= children.length) return;
106
- return createItem(generator ? generator(i) : children[i]);
149
+ return createItem(generator ? generator(i, children[i]) : children[i]);
107
150
  });
108
151
  once("mounted")(page, function () {
109
152
  var index = 0;
@@ -220,6 +263,6 @@ function main() {
220
263
  };
221
264
  bind('keydown.enter')(page, enter);
222
265
  bind('keydown.space')(page, enter);
223
- on('mousedown')(page, e => e.preventDefault());
266
+ on('mousedown')(page, e => !/^input$/i.test(e.target.tagName) && e.preventDefault());
224
267
  return page;
225
268
  }
@@ -78,4 +78,50 @@
78
78
  vertical-align: top;
79
79
  margin-left: 10px;
80
80
  }
81
+ }
82
+
83
+ &>input {
84
+ height: 28px;
85
+ line-height: 28px;
86
+ padding: 0 16px;
87
+ border: none;
88
+ appearance: none;
89
+ width: 100%;
90
+ min-width: 0;
91
+ box-sizing: border-box;
92
+ display: block;
93
+ position: sticky;
94
+ top: 0;
95
+ border-bottom: 1px solid #0006;
96
+
97
+ &:focus {
98
+ outline-offset: -1px;
99
+ outline: 1px solid #2ca2f9;
100
+ }
101
+ }
102
+
103
+ &[searching] {
104
+ &::before {
105
+ content: "正在搜索..";
106
+ position: absolute;
107
+ left: 0;
108
+ top: 0;
109
+ right: 0;
110
+ display: block;
111
+ font-size: 12px;
112
+ text-align: right;
113
+ pointer-events: none;
114
+ padding: 0 16px;
115
+ }
116
+ }
117
+
118
+ &[empty] {
119
+ background-color: #fff;
120
+ }
121
+
122
+ b {
123
+ border: 1px solid #29e;
124
+ background-color: #29e2;
125
+ font-weight: 400;
126
+ border-radius: 2px;
81
127
  }
@@ -10,5 +10,5 @@
10
10
  </select>
11
11
  <select -src="(o,i) in options6000">
12
12
  <option value="" insert selected>60000个选项</option>
13
- <option -text="'选项'+o">选项</option>
13
+ <option -html="'选项'+o">选项</option>
14
14
  </select>
@@ -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')">
@@ -7,50 +7,36 @@ function createTouchEvent(eventtype, extra = {}) {
7
7
  }
8
8
 
9
9
 
10
- function _test_scroll(banner) {
11
- var clientY = 10;
12
- var touchstartEvent = createTouchEvent("touchstart", { clientY });
10
+ function _test_scroll() {
11
+ var banner = this;
12
+ var clientY = 2;
13
+ var touchstartEvent = createTouchEvent("touchstart", { clientY, clientX: 0 });
13
14
  var deltaY = 100;
15
+ onclick.preventClick = true;
14
16
  dispatch(banner, touchstartEvent);
15
17
  var interval_handle = setInterval(function () {
16
- clientY -= deltaY;
17
- var touchmoveEvent = createTouchEvent("touchmove", { clientY });
18
- dispatch(banner, touchmoveEvent);
18
+ clientY += deltaY;
19
+ var touchmoveEvent = createTouchEvent("touchmove", { clientY, clientX: 0 });
20
+ dispatch(window, touchmoveEvent);
19
21
  }, 10);
20
22
 
21
23
  setTimeout(function () {
22
- deltaY = -10
23
- }, 300);
24
+ deltaY = -2
25
+ }, 200);
24
26
  setTimeout(function () {
25
- deltaY = 100
27
+ deltaY = 5
26
28
  }, 400);
27
- setTimeout(function () {
28
- deltaY = -10
29
- }, 420);
30
- setTimeout(function () {
31
- deltaY = -50
32
- }, 450);
33
- setTimeout(function () {
34
- deltaY = 50
35
- }, 470);
36
- setTimeout(function () {
37
- deltaY = -100050
38
- }, 480);
39
- setTimeout(function () {
40
- deltaY = +100050
41
- }, 490);
42
29
  setTimeout(function () {
43
30
  clearInterval(interval_handle);
31
+ }, 510);
32
+ setTimeout(function () {
44
33
  var touchendEvent = createTouchEvent("touchend");
34
+ touchendEvent.touches.pop();
45
35
  dispatch(banner, touchendEvent);
46
- }, 510);
36
+ }, 560);
47
37
  }
48
38
 
49
- function main(banner){
50
- if(banner.isMounted){
51
- _test_scroll(banner);
52
- }else{
53
- on("append")(banner,_test_scroll);
54
- }
39
+ function main(banner) {
40
+ oncemount(banner, _test_scroll);
55
41
 
56
42
  }
@@ -2,7 +2,7 @@ function vbox_test() {
2
2
  var vbox1 = vbox();
3
3
  var vbox2 = vbox();
4
4
  vbox2.innerHTML = '<span></span>';
5
- test_scroll(vbox2);
6
5
  appendChild(vbox1, vbox2);
6
+ test_scroll(vbox2);
7
7
  return vbox1;
8
8
  }
@@ -1,6 +1,6 @@
1
1
 
2
2
  var prototype = {
3
- dragable: undefined,
3
+ draggable: undefined,
4
4
  resizable: false,
5
5
  closeable: true,
6
6
  showTitle: true,
@@ -98,10 +98,10 @@ function view(element) {
98
98
  if (window !== element) {
99
99
  extend(window, element);
100
100
  once("append")(window, function () {
101
- if (window.dragable !== true && window.dragable !== false) {
102
- window.dragable = /^(fixed|absolute)$/i.test(getComputedStyle(window).position);
101
+ if (window.draggable !== true && window.draggable !== false) {
102
+ window.draggable = /^(fixed|absolute)$/i.test(getComputedStyle(window).position);
103
103
  }
104
- if (window.dragable) window.setAttribute('dragable', 'dragable');
104
+ if (window.draggable) window.setAttribute('draggable', 'draggable');
105
105
  })
106
106
  if (window.resizable) resize.on(window);
107
107
  }
@@ -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.6",
3
+ "version": "3.22.9",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {