efront 3.25.3 → 3.25.7

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,5 +1,5 @@
1
1
  <div class="searchbox">
2
- <input @input="filter" -model="searchText" />
2
+ <input -model="searchText" />
3
3
  </div>
4
- <table -src="[fields,items]">
4
+ <table -src="[fields,items]" _find="searchText">
5
5
  </talbe>
@@ -0,0 +1,5 @@
1
+ class Field {
2
+ key = '';
3
+ name = '';
4
+ sort = 0;
5
+ }
@@ -38,7 +38,7 @@ class Item extends Array {
38
38
  return this.value;
39
39
  }
40
40
  toString() {
41
- return String(this.value);
41
+ return String(this.name);
42
42
  }
43
43
  get warn() {
44
44
  if (isObject(this.value)) {
@@ -47,8 +47,8 @@ class Item extends Array {
47
47
  return false;
48
48
  }
49
49
  get name() {
50
- if (isObject(this.value)) return this.value.name;
51
- return this.value;
50
+ if (isObject(this.value)) return getName(this.value);
51
+ return String(this.value);
52
52
  }
53
53
 
54
54
  isClosed() {
@@ -0,0 +1,120 @@
1
+
2
+ function minusPower(a, b) {
3
+ return a.power - b.power >= 0;
4
+ }
5
+ function returnName() {
6
+ return this.name;
7
+ }
8
+ function searchThis(field) {
9
+ return /^$|text|input|html/i.test(field.type);
10
+ }
11
+ class Table extends Array {
12
+ searchText = null;
13
+ sortFields = [];
14
+ searchFields = null;
15
+ fields = [];
16
+ sorted = null;
17
+ source = null;
18
+ complete = true;
19
+ searched = 0;
20
+ searchid = 0;
21
+ coverCount = 0;
22
+ hasFullmatch = false;
23
+ callback = null;
24
+ static from(fields, data) {
25
+ var t = new Table;
26
+ t.fields = fields;
27
+ t.source = data;
28
+ t.searchFields = fields.filter(searchThis);
29
+ t.update();
30
+ return t;
31
+ }
32
+ /**
33
+ * @param {Field} field
34
+ */
35
+ sort(field) {
36
+ removeFromList(this.sortFields, field);
37
+ this.sortFields.push(field);
38
+ var sorted = this.sorted || this.source.slice(0);
39
+ field.sort = field.sort > 0 ? -1 : 1;
40
+ this.sorted = sorted.sort(function (a, b) {
41
+ a = seek(a, field.key);
42
+ b = seek(b, field.key);
43
+ if (a > b) return field.sort;
44
+ if (a < b) return -field.sort;
45
+ return 0;
46
+ });
47
+ this.update();
48
+ }
49
+ unsort() {
50
+ this.sorted = null;
51
+ this.update();
52
+ }
53
+ addItem(o) {
54
+ if (isEmpty(o)) return;
55
+ var searchtext = this.searchText;
56
+ var fields = this.searchFields ? this.searchFields : this.fields;
57
+ var power = 0;
58
+ if (isNode(o)) {
59
+ o = extend({
60
+ name: o.name,
61
+ title: o.title,
62
+ value: o.value,
63
+ key: o.key,
64
+ nodeType: o.nodeType,
65
+ tagName: o.tagName,
66
+ nodeValue: o.nodeValue,
67
+ }, o);
68
+ }
69
+ else o = isObject(o) ? Object.create(o) : new o.constructor(o);
70
+ for (var f of fields) {
71
+ var name = seek(o, f.key);
72
+ if (isEmpty(name) || !isString(name)) continue;
73
+ if (name === searchtext) this.hasFullmatch = true;
74
+ var [p, m] = mark.power(name, searchtext);
75
+ power += p;
76
+ if (p >= searchtext.length) this.coverCount++;
77
+ if (isString(f.key)) o[f.key] = m;
78
+ else o.name = m, o.toString = returnName, o.valueOf = returnName;
79
+ }
80
+ o.power = power;
81
+ if (o.power > 0) {
82
+ saveToOrderedArray(this, o, minusPower);
83
+ }
84
+ }
85
+ search(text, callback) {
86
+ if (isFunction(callback)) this.callback = callback;
87
+ if (text === this.searchText) return;
88
+ this.searchText = text;
89
+ this.update();
90
+ }
91
+ async update() {
92
+ this.searched = 0;
93
+ this.splice(0, this.length);
94
+ var source = this.sorted ? this.sorted : this.source;
95
+ var searchid = ++this.searchid;
96
+ this.complete = false;
97
+ this.coverCount = 0;
98
+ if (this.searchText) for (var o of source) {
99
+ this.addItem(o);
100
+ if (++this.searched % 600 === 0) {
101
+ if (isFunction(this.callback)) this.callback();
102
+ await new Promise(function (ok) {
103
+ requestAnimationFrame(ok)
104
+ });
105
+ if (this.searchid !== searchid) break;
106
+ }
107
+ }
108
+ else {
109
+ while (this.searched < source.length) {
110
+ this.push.apply(this, source.slice(this.searched, this.searched += 6000));
111
+ }
112
+ this.searched = source.length;
113
+ }
114
+ this.complete = true;
115
+ if (isFunction(this.callback)) this.callback();
116
+ }
117
+ abort() {
118
+ this.searchid++;
119
+ }
120
+ }
@@ -57,8 +57,8 @@ var power = function (source, search) {
57
57
  var match_start2 = matchers[1];
58
58
  if (search.length === 1) {
59
59
  var p = 0;
60
- var res = source.replace(new RegExp(search.replace(/[\\\*\?\+\(\)\[]/g, "\\$&"), "g"), () => {
61
- if (!p) p = 1;
60
+ var res = source.replace(new RegExp(search.replace(/[\\\*\?\+\(\)\[]/g, "\\$&"), "g"), (m, i) => {
61
+ if (!p) p = .1 / (1 + i);
62
62
  return MARK_PRE1 + search + MARK_AFT1;
63
63
  });
64
64
  return [p, res];
@@ -68,15 +68,17 @@ var power = function (source, search) {
68
68
  var match_text_aft = source.slice(match_start2 + match_text.length);
69
69
  var pp = 0, ap = 0;
70
70
  var p = match_text.length;
71
- if (match_text_pre.length) p += .1 / match_text_pre.length - .2;
72
- if (match_text_aft.length) p += .1 / match_text_aft.length - .1;
71
+ p = match_text.length;
72
+ if (match_start2) p += .1 / match_start2;
73
73
  if (match_text_pre.length > 1) {
74
74
  [pp, match_text_pre] = power(match_text_pre, search);
75
75
  }
76
76
  if (match_text_aft.length > 1) {
77
77
  [ap, match_text_aft] = power(match_text_aft, search);
78
78
  }
79
- p += (pp + ap) * .01;
79
+ if (match_text.length !== search.length) {
80
+ p += (pp + ap) / source.length / search.length * .01 - .2;
81
+ }
80
82
  return [p, match_text_pre.concat(MARK_PRE1, match_text, MARK_AFT1, match_text_aft)];
81
83
  }
82
84
  return [0, source];
@@ -25,7 +25,7 @@ function parseKV(string) {
25
25
  if (index < 0) index = kv.length;
26
26
  var k = kv.slice(0, index);
27
27
  var v = kv.slice(index + 1);
28
- if (isFunction(decode)) {
28
+ if (typeof decode === 'function') {
29
29
  k = decode(k);
30
30
  v = decode(v);
31
31
  }
@@ -0,0 +1,6 @@
1
+ function with_(k, objlist) {
2
+ for (var o of objlist) {
3
+ if (k in o) return o;
4
+ }
5
+ return;
6
+ }
@@ -0,0 +1,6 @@
1
+ function withget_(k, objlist, v) {
2
+ for (var o of objlist) {
3
+ if (k in o) return o[k];
4
+ }
5
+ return v;
6
+ }
@@ -96,7 +96,8 @@ var parse = function (r) {
96
96
  case 18:
97
97
  s = r.slice(17, 18);
98
98
  case 17:
99
- o = r.slice(14, 17);
99
+ o = r.slice(14, 17) >> 1;
100
+ x = r.slice(16, 17) & 1;
100
101
  case 14:
101
102
  d = r.slice(12, 14);
102
103
  case 12:
@@ -117,7 +118,7 @@ var parse = function (r) {
117
118
  case 3:
118
119
  o = r >> 1;
119
120
  case 1:
120
- x = o & 1;
121
+ x = r & 1;
121
122
  break;
122
123
  case 2:
123
124
  m = r;
@@ -135,7 +136,7 @@ function 身份证(r) {
135
136
  var q = r0 * 20220309 | 0;
136
137
  var d = birth(q);
137
138
  var [p = code(q), y = d.getFullYear(), m = d.getMonth() + 1, d = d.getDate(), o = order(r0), x = sex(r0)] = parse(r);
138
- middle = (y * 10000 + m * 100 + d) * 1000 + (o << 1 | x);
139
+ middle = (y * 10000 + m * 100 + +d) * 1000 + (o << 1 | x);
139
140
  p17 = p + middle;
140
141
  }
141
142
  if (!p17) {
@@ -8,7 +8,7 @@ styles.success = styles.pass = styles.green;
8
8
  styles.info = styles.blue;
9
9
  styles.error = styles.danger = styles.red;
10
10
  styles.warn = styles.orange;
11
- styles.default = '#000';
11
+ styles.default = '#000a';
12
12
  var alerts = [];
13
13
  var clean = Cleanup(alerts);
14
14
  var build = function () {
@@ -24,14 +24,13 @@ var fontSize = 16;
24
24
  var singleHeight = fontSize * 3.125 | 0;
25
25
  var _text = function (bgcolor, parameters) {
26
26
  var box = div();
27
- css(box, `top:${fromPixel(alerts.length ? Math.max.apply(Math, alerts.map(e => e.offsetTop + e.children[0].offsetHeight)) : 0)};height:0;line-height:${fromPixel(singleHeight - 20)};left:0;right:0;font-size:${fromPixel(fontSize)}; transition: all 0.2s ease-out;position:absolute;color:#fff;text-align:center;`);
28
- box.innerHTML = `<div style='width: 720px;white-space:pre-wrap;max-width:100%;display:inline-block;height:auto;padding:${fromPixel(10)} ${fromPixel(20)};background-color:${bgcolor};color:${color.pair(bgcolor)};'>${[].slice.call(parameters, 0).join(", ")}</div>`;
27
+ css(box, `top:${fromPixel(alerts.length ? Math.max.apply(Math, alerts.map(e => e.offsetTop + e.children[0].offsetHeight)) : 0)};height:0;line-height:${fromPixel(singleHeight - 20)};left:0;right:0;font-size:${fromPixel(fontSize)}; transition: all 0.2s ease-out;position:absolute;text-align:center;`);
28
+ box.innerHTML = `<div style='width: 720px;white-space:pre-wrap;max-width:100%;display:inline-block;height:auto;padding:${fromPixel(10)} ${fromPixel(20)};background-color:${bgcolor};color:${color.pair(bgcolor, 1)};'>${[].slice.call(parameters, 0).join(", ")}</div>`;
29
29
  box.initialStyle = `margin:-${fromPixel(singleHeight)} auto;opacity:0;`;
30
30
  return box;
31
31
  };
32
32
  function alert() {
33
- var color = String(isString(this) && this || styles.default), text, autoclose = true, onclose;
34
- var color_reg = /^#(?:\w{6}|\w{3})$/;
33
+ var clr = String(isString(this) && this || styles.default), text, autoclose = true, onclose;
35
34
  [].map.call(arguments, function (arg) {
36
35
  switch (typeof arg) {
37
36
  case "string":
@@ -39,16 +38,16 @@ function alert() {
39
38
  arg = String(arg);
40
39
  if (!text) {
41
40
  text = arg;
42
- } else if (color_reg.test(text)) {
43
- color = text;
41
+ } else if (color.isColor(text)) {
42
+ clr = text;
44
43
  text = arg;
45
44
  } else if (text in styles) {
46
- color = styles[text];
45
+ clr = styles[text];
47
46
  text = arg;
48
47
  } else if (arg in styles) {
49
- color = styles[arg];
50
- } else if (color_reg.test(arg)) {
51
- color = arg;
48
+ clr = styles[arg];
49
+ } else if (color.isColor(arg)) {
50
+ clr = arg;
52
51
  }
53
52
  break;
54
53
  case "boolean":
@@ -61,8 +60,8 @@ function alert() {
61
60
  });
62
61
  var elem;
63
62
 
64
- if (color_reg.test(color)) {
65
- elem = _text(color, [text]);
63
+ if (color.isColor(clr)) {
64
+ elem = _text(clr, [text]);
66
65
  } else {
67
66
  elem = _text(styles.log, [text]);
68
67
  }
@@ -331,13 +331,16 @@ var hooka = function (matcher, move, event, targetChild, isMovingSource) {
331
331
  followedElements.splice(0, followedElements.length);
332
332
  previousElements.push.apply(previousElements, _previousElements);
333
333
  followedElements.push.apply(followedElements, _followedElements);
334
- setOpacity(targetBox, draggingSourceOpacity);
335
334
  appendChild(document.body, previousElements);
336
335
  appendChild(document.body, followedElements);
337
336
  var offall = function () {
337
+ offdragstart();
338
338
  offdragmove();
339
339
  offdragend();
340
340
  };
341
+ var offdragstart = on('dragstart')(targetChild, function () {
342
+ setOpacity(targetBox, draggingSourceOpacity);
343
+ });
341
344
  var offdragend = on("dragend")(targetChild, function () {
342
345
  offall();
343
346
  dragfire();
@@ -71,9 +71,12 @@ var cloneChildren = function (td, copy, clone) {
71
71
  if (after) copy.appendChild(after);
72
72
 
73
73
  };
74
+ /**
75
+ * @param {Node}
76
+ */
74
77
  var isMaybeVisible = function (node) {
75
78
  if (!node || !node.parentNode || node.nodeType > 3 || node.nodeType === 2) return;
76
- if (/^(style|link|script|meta)$/i.test(node)) return;
79
+ if (/^(style|link|script|meta)$/i.test(node.tagName)) return;
77
80
  var style = node.style;
78
81
  if (!style) {
79
82
  node = node.parentNode;
@@ -88,7 +91,6 @@ var isMaybeVisible = function (node) {
88
91
  }
89
92
  if (node.offsetParent) {
90
93
  var parent = node.offsetParent;
91
- if (!isMaybeVisible(parent)) return false;
92
94
  if (getComputedStyle(parent).overflow === 'visible') return true;
93
95
  return !(node.offsetLeft + node.offsetWidth - parent.scrollLeft <= parent.clientLeft ||
94
96
  node.offsetTop + node.offsetHeight - parent.scrollTop <= parent.clientTop ||
@@ -128,9 +130,13 @@ var cloneCanvas = function (canvas) {
128
130
  };
129
131
  var cloneVisible = function (td) {
130
132
  var result = document.createElement("clone");
133
+ if (!isMaybeVisible(td.offsetParent)) return result;
131
134
  var _left, _top, _right, _bottom;
132
135
  var span = document.createElement("x");
133
136
  var hasSvg = false;
137
+ /**
138
+ * @param {Node} td
139
+ */
134
140
  var clone = function (td) {
135
141
  if (!isMaybeVisible(td)) return;
136
142
  if (td.nodeType === 3) {
@@ -346,7 +346,7 @@ var v2rgb = function (v, r, g, b) {
346
346
  return [r, g, b];
347
347
  };
348
348
 
349
- var gray4 = function (RGBA, S) {
349
+ var gray4 = function (RGBA, A) {
350
350
  var [r, g, b, a] = RGBA;
351
351
  var v = rgb2v(r, g, b);
352
352
  var s = rgb2s(r, g, b);
@@ -358,13 +358,18 @@ var gray4 = function (RGBA, S) {
358
358
  else if (v > .6 * 255) {
359
359
  v = v - p * s - p;
360
360
  s = 1;
361
+ if (v < 0) v = - v;
361
362
  }
362
363
  else {
363
364
  v = 255;
364
365
  }
366
+ if (s > .8) {
367
+ r = 255 + r >> 1, g = 255 + g >> 1, b = 255 + b >> 1;
368
+ s = .3;
369
+ }
365
370
  [r, g, b] = rgb4s(r, g, b, s);
366
371
  [r, g, b] = rgb4v(r, g, b, v);
367
- return [r, g, b, a];
372
+ return [r, g, b, A || a];
368
373
  };
369
374
 
370
375
 
@@ -391,8 +396,8 @@ extend(color, {
391
396
  parse,
392
397
  equal,
393
398
  stringify,
394
- pair(c, s) {
395
- return doWith(gray4, c, s);
399
+ pair(c, alpha) {
400
+ return doWith(gray4, c, alpha);
396
401
  },
397
402
  isColor,
398
403
  transform(text) {
@@ -39,7 +39,6 @@ function contextmenu(target, menuItems) {
39
39
  bindtouch(target, {
40
40
  start(event) {
41
41
  if (event.defaultPrevented) return;
42
- event.preventDefault();
43
42
  clearTimeout(menuHandle);
44
43
  if (tm) remove(tm), tm = null;
45
44
  menuHandle = setTimeout(function () {
@@ -66,6 +65,7 @@ function contextmenu(target, menuItems) {
66
65
  event.preventDefault();
67
66
  if (tm) remove(tm), tm = null;
68
67
  tm = showContext(event);
68
+ if (!tm) return;
69
69
  tm.focus();
70
70
  onblur(tm, lazy(e => remove(tm)));
71
71
  });
@@ -62,7 +62,6 @@ function drag(target, initialEvent, preventOverflow, isMovingSource) {
62
62
  if (!onclick.preventClick) return;
63
63
  saved_delta.ing = true;
64
64
  drag.target = target;
65
- dispatch("dragstart", target);
66
65
  if (isElement(target) && !/absolute|fixed/.test(getComputedStyle(target).position)) {
67
66
  clone = toCloneTarget(target, isMovingSource);
68
67
  z = zIndex(0) + 1;
@@ -79,6 +78,7 @@ function drag(target, initialEvent, preventOverflow, isMovingSource) {
79
78
  extraClones.map(c => document.body.appendChild(c));
80
79
  saved_delta.x += clone_left - target_left;
81
80
  saved_delta.y += clone_top - target_top;
81
+ dispatch("dragstart", target);
82
82
  }
83
83
  event.moveLocked = true;
84
84
  drag.target = clone;
@@ -1,9 +1,17 @@
1
1
  var hasOwnProperty = {}.hasOwnProperty;
2
2
  function getName(o) {
3
- if (hasOwnProperty.call(o, 'toString')) return o.toString();
4
- if ("name" in o) return o.name;
5
- if ("label" in o) return o.label;
6
- if ("value" in o) return o.value;
7
- if (hasOwnProperty.call(o, 'valueOf')) return o.valueOf();
8
- return o;
3
+ var name;
4
+ if (isEmpty(o)) return '';
5
+ if (!isObject(o)) return String(o);
6
+ if (hasOwnProperty.call(o, 'toString')) {
7
+ name = o.toString();
8
+ if (!isEmpty(name)) return String(name);
9
+ }
10
+ if (!isEmpty(o.name)) return String(o.name);
11
+ if (!isEmpty(o.title)) return String(o.title);
12
+ if (!isEmpty(o.label)) return String(o.label);
13
+ if (!isEmpty(o.value)) return String(o.value);
14
+ if (hasOwnProperty.call(o, 'valueOf')) name = o.valueOf();
15
+ if (!isEmpty(name)) return String(name);
16
+ return String(o);
9
17
  }
@@ -1,3 +1,4 @@
1
+ var _active = action;
1
2
  var mounted_menus = [], releaseTimer = 0, root_menu;
2
3
  var release = function () {
3
4
  clear();
@@ -164,9 +165,16 @@ function register() {
164
165
  on('keydown.space')(menu, keyspace);
165
166
  on("contextmenu")(menu, e => e.preventDefault());
166
167
  }
167
- function main(page, items, active, direction = 'y') {
168
+ function main() {
169
+ var page, items, active = _active, direction = 'y';
170
+ for (var a of arguments) {
171
+ if (isNode(a)) page = a;
172
+ else if (a instanceof Function) active = a;
173
+ else if (a instanceof Array) items = a;
174
+ else if (typeof a === 'string') direction = a;
175
+ }
168
176
  if (!isNode(page)) {
169
- var page = document.createElement("menu-list");
177
+ page = document.createElement("menu-list");
170
178
  }
171
179
  var main = this;
172
180
  if (direction == 'y') page.ispop = true;
@@ -188,6 +196,7 @@ function main(page, items, active, direction = 'y') {
188
196
  mounted_menus.push(menu);
189
197
  page.actived = menu;
190
198
  menu.root = page.root || page;
199
+ menu.go(0);
191
200
  popup(menu, target);
192
201
  if (page.ispop === true) {
193
202
  } else {
@@ -199,7 +208,6 @@ function main(page, items, active, direction = 'y') {
199
208
  once("remove")(menu, function () {
200
209
  removeFromList(mounted_menus, this);
201
210
  });
202
- menu.go(0);
203
211
  }
204
212
  on("blur")(page, unfocus);
205
213
  var template = page.tempalte || document.createElement("ylist");
@@ -216,12 +224,12 @@ function main(page, items, active, direction = 'y') {
216
224
  time = +time;
217
225
  if (byMousedown && !time) return;
218
226
  if (time) byMousedown = false;
219
-
227
+
220
228
  if (page.ispop || time) popTimer = setTimeout(function () {
221
229
  if (time) byMousedown = elem;
222
230
  page.setFocus(elem);
223
231
  popMenu(elem.menu, elem);
224
- }, time || 60);
232
+ }, time || 10);
225
233
  };
226
234
  var cancel = function () {
227
235
  clear();
@@ -15,7 +15,7 @@ var isequal = (a, b) => a === b || Math.abs(a - b) < .1;
15
15
  var aimed = (from, to) => (from + from + from + to) / 4;
16
16
  function picture_(image = document.createElement("div")) {
17
17
  var image_width, image_height;
18
- var scaled = 1, x = 0, y = 0, min_scale, cover_scale, isxrelex, contain_scale, loaded_scale, click_scale, loaded_x, loaded_y;
18
+ var scaled = 1, x = 0, y = 0, min_scale, cover_scale, isxthin, contain_scale, loaded_scale, click_scale, loaded_x, loaded_y;
19
19
  var loaded_width, loaded_height;
20
20
  var max_scale = 10 * devicePixelRatio;
21
21
  var istouching = false;
@@ -38,14 +38,14 @@ function picture_(image = document.createElement("div")) {
38
38
  deltay = y + image_height * scaled / 2 - loaded_height / 2;
39
39
  }
40
40
  else if (scaled <= cover_scale) {
41
- if (isxrelex) {
42
- if (x > 0) deltax = x;
43
- else if (x + image_width * scaled < loaded_width) deltax = loaded_width - x + image_width * scaled;
44
- deltay = y + image_height * scaled / 2 - loaded_height / 2;
45
- } else {
46
- if (y > 0) deltay = y;
41
+ if (isxthin) {
42
+ if (y >= 0) deltay = y;
47
43
  else if (y + image_height * scaled < loaded_height) deltay = y + image_height * scaled - loaded_height;
48
44
  deltax = x + image_width * scaled / 2 - loaded_width / 2;
45
+ } else {
46
+ if (x >= 0) deltax = x;
47
+ else if (x + image_width * scaled < loaded_width) deltax = loaded_width - x + image_width * scaled;
48
+ deltay = y + image_height * scaled / 2 - loaded_height / 2;
49
49
  }
50
50
  }
51
51
  else {
@@ -81,9 +81,9 @@ function picture_(image = document.createElement("div")) {
81
81
  shaped_rotate = 0;
82
82
  var y_scale = loaded_height / image_height;
83
83
  var x_scale = loaded_width / image_width;
84
- isxrelex = x_scale > y_scale;
85
- cover_scale = isxrelex ? x_scale : y_scale;
86
- loaded_scale = contain_scale = isxrelex ? y_scale : x_scale;
84
+ isxthin = x_scale > y_scale;
85
+ cover_scale = isxthin ? x_scale : y_scale;
86
+ loaded_scale = contain_scale = isxthin ? y_scale : x_scale;
87
87
  if (loaded_scale >= 1) {
88
88
  if (loaded_scale > devicePixelRatio) {
89
89
  loaded_scale = devicePixelRatio;
@@ -278,6 +278,7 @@ var _as_yextra = function (global, innerWidth, innerHeight, element, target, poi
278
278
 
279
279
  css(element, `min-width:auto;`);
280
280
  var aimedWidth = getScreenPosition(element).width;
281
+ var originWidth = aimedWidth;
281
282
  //如果宽度不足其附着元素的宽度
282
283
  if (aimedWidth < position.width) {
283
284
  aimedWidth = position.width;
@@ -288,7 +289,8 @@ var _as_yextra = function (global, innerWidth, innerHeight, element, target, poi
288
289
  aimedWidth = maxWidth;
289
290
  }
290
291
  var side;
291
- if (aimedWidth !== element.offsetWidth) {
292
+ if (aimedWidth !== originWidth) {
293
+ console.log(originWidth,aimedWidth)
292
294
  css(element, { width: fromOffset(aimedWidth) });
293
295
  }
294
296
  if (position.top + element.offsetHeight + position.height > innerHeight) {
@@ -303,7 +305,7 @@ var _as_yextra = function (global, innerWidth, innerHeight, element, target, poi
303
305
  css(_rhomb, temp);
304
306
  _rhomb.setSide(side);
305
307
  }
306
- var targetX = position.left + (position.width - element.offsetWidth) / 2;
308
+ var targetX = position.left - parseFloat(getComputedStyle(element).paddingLeft);
307
309
  if (targetX < 0) {
308
310
  css(element, `left:0;right:auto`);
309
311
  if (_rhomb) css(_rhomb, `left:${fromOffset(position.left + position.width / 2)};right:auto`);
@@ -1,77 +1,8 @@
1
1
  function search(seartext, options, path = "name") {
2
- var a = new SearchResult;
3
- a.searchPath = path;
2
+ var a = new Table;
3
+ a.searchFields = [{ key: path }];
4
4
  a.searchText = seartext;
5
5
  a.source = options;
6
- if (a.searchText) a.start();
6
+ if (a.searchText) a.update();
7
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++;
76
- }
77
8
  }
@@ -243,7 +243,8 @@ function main() {
243
243
  moveFocus(-focus);
244
244
  });
245
245
  bind("keydown.end")(page, function (e) {
246
- moveFocus(children.length - 1 - focus);
246
+ var coverIndex = children.coverCount > focus + 1 ? children.coverCount - 1 : children.length - 1;
247
+ moveFocus(coverIndex - focus);
247
248
  });
248
249
  bind("keydown.pagedown")(page, function (e) {
249
250
  page.scrollBy(page.clientHeight);