efront 3.12.0 → 3.12.1
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/basic/sortname.js +6 -2
- package/coms/zimoli/getGenerator.js +2 -2
- package/coms/zimoli/list.js +38 -11
- package/coms/zimoli/list_test.js +2 -2
- package/coms/zimoli/menu.js +1 -0
- package/coms/zimoli/menuList.js +12 -12
- package/coms/zimoli/on.js +2 -2
- package/coms/zimoli/select.js +26 -1
- package/coms/zimoli/selectList.js +89 -5
- package/coms/zimoli/selectList.less +1 -1
- package/coms/zimoli/selectList_test.html +7 -3
- package/coms/zimoli/selectList_test.js +9 -3
- package/coms/zimoli/touchList_test.js +2 -2
- package/package.json +1 -1
- package/public/efront.js +1 -1
- package/readme.md +7 -0
package/coms/basic/sortname.js
CHANGED
|
@@ -48,11 +48,13 @@ var parse一二三 = function (a) {
|
|
|
48
48
|
};
|
|
49
49
|
var map甲乙丙 = createMap("甲乙丙丁戊己庚辛壬癸");
|
|
50
50
|
var map子丑寅 = createMap("子丑寅卯辰巳午未申酉戌亥");
|
|
51
|
+
var map上中下 = createMap("前上中下后");
|
|
51
52
|
|
|
52
53
|
var reg123 = /^(\d+|\d+[\.\d]+\d+)[\s\S]*$/;
|
|
53
54
|
var reg一二三 = /^([一二三四五六七八九十百千万亿壹贰叁肆伍陆柒捌玖拾佰仟萬零〇]+)[\s\S]*$/;
|
|
54
55
|
var reg甲乙丙 = /^([甲乙丙丁戊己庚辛壬癸])[\s\S]*$/;
|
|
55
56
|
var reg子丑寅 = /^([子丑寅卯辰巳午未申酉戌亥])[\s\S]*$/;
|
|
57
|
+
var reg上中下 = /^([前上中下后])[\s\S]*$/;
|
|
56
58
|
var reg天干地支 = /^([甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥])[\s\S]*$/;
|
|
57
59
|
|
|
58
60
|
var getDelta = function (a, b, reg, parse) {
|
|
@@ -85,14 +87,14 @@ var compare = function (a, b) {
|
|
|
85
87
|
for (var cx1 = a.length - 1, cx2 = b.length - 1; cx1 >= 0 && cx2 >= 0; cx1--, cx2--) {
|
|
86
88
|
while (/\s\u00a0/.test(a[cx1])) cx1--;
|
|
87
89
|
while (/\s\u00a0/.test(b[cx2])) cx2--;
|
|
88
|
-
if (a[cx1] !== b[cx2] || a[cx1] in map子丑寅 || a[cx1] in map一二三 || a in power || /^\d$/.test(a[cx1])) break;
|
|
90
|
+
if (a[cx1] !== b[cx2] || a[cx1] in map子丑寅 || a[cx1] in map上中下 || a[cx1] in map一二三 || a in power || /^\d$/.test(a[cx1])) break;
|
|
89
91
|
}
|
|
90
92
|
a = a.slice(0, cx1 + 1);
|
|
91
93
|
b = b.slice(0, cx2 + 1);
|
|
92
94
|
for (var cx1 = 0, cx2 = 0, dx1 = b.length, dx2 = b.length; cx1 < dx1 && cx2 < dx2; cx1++, cx2++) {
|
|
93
95
|
while (/[\s\u00a0]/.test(a[cx1])) cx1++;
|
|
94
96
|
while (/[\s\u00a0]/.test(b[cx2])) cx2++;
|
|
95
|
-
if (a[cx1] !== b[cx2] || a[cx1] in map甲乙丙 || a[cx1] in map一二三 || a in power || /^\d/.test(a[cx1])) break;
|
|
97
|
+
if (a[cx1] !== b[cx2] || a[cx1] in map甲乙丙 || a[cx1] in map上中下 || a[cx1] in map一二三 || a in power || /^\d/.test(a[cx1])) break;
|
|
96
98
|
}
|
|
97
99
|
if (cx1) a = a.slice(cx1);
|
|
98
100
|
if (cx2) b = b.slice(cx2);
|
|
@@ -108,6 +110,8 @@ var compare = function (a, b) {
|
|
|
108
110
|
if (delta) return delta;
|
|
109
111
|
delta = getDelta(a, b, reg子丑寅, d => map子丑寅[d]);
|
|
110
112
|
if (delta) return delta;
|
|
113
|
+
delta = getDelta(a, b, reg上中下, d => map上中下[d]);
|
|
114
|
+
if (delta) return delta;
|
|
111
115
|
return 0;
|
|
112
116
|
}
|
|
113
117
|
function sortname(list = this) {
|
|
@@ -24,11 +24,11 @@ var getGenerator = function (container, tagName = 'item') {
|
|
|
24
24
|
var scopes = container.$parentScopes || [];
|
|
25
25
|
if (container.$scope) scopes = scopes.concat(container.$scope);
|
|
26
26
|
return container.$generator = function (index, com, element) {
|
|
27
|
-
if (
|
|
27
|
+
if (com === undefined) {
|
|
28
28
|
if (!container.src || index >= container.src.length) return;
|
|
29
29
|
com = container.src[index];
|
|
30
30
|
}
|
|
31
|
-
if (
|
|
31
|
+
if (com === undefined) return;
|
|
32
32
|
if (!element) {
|
|
33
33
|
var template1 = template.cloneNode(true);
|
|
34
34
|
if (!template1.childNodes.length) {
|
package/coms/zimoli/list.js
CHANGED
|
@@ -60,6 +60,28 @@ function ylist(container, generator, $Y) {
|
|
|
60
60
|
}
|
|
61
61
|
return null;
|
|
62
62
|
};
|
|
63
|
+
var hasCover = function (child) {
|
|
64
|
+
var scrollTop = list.scrollTop;
|
|
65
|
+
if (child.offsetTop + child.offsetHeight < scrollTop || child.offsetTop >= scrollTop + list.clientHeight) return false;
|
|
66
|
+
if (child.offsetTop <= scrollTop && child.offsetTop + child.offsetHeight >= scrollTop + list.clientHeight) return true;
|
|
67
|
+
if (child.offsetTop < scrollTop) return false;
|
|
68
|
+
if (child.offsetTop + child.offsetHeight > scrollTop + list.clientHeight) return false;
|
|
69
|
+
return true;
|
|
70
|
+
};
|
|
71
|
+
var scrollIfNotCover = function (index) {
|
|
72
|
+
var c = getIndexedElement(index);
|
|
73
|
+
if (!c) return scrollTo(index);
|
|
74
|
+
if (hasCover(c)) return;
|
|
75
|
+
var scrollTop = list.scrollTop;
|
|
76
|
+
var deltat = scrollTop - c.offsetTop;
|
|
77
|
+
var deltab = c.offsetTop + c.offsetHeight - scrollTop - list.clientHeight;
|
|
78
|
+
if (deltat > 0) {
|
|
79
|
+
return scrollBy(-deltab > deltat ? -deltat : -deltab);
|
|
80
|
+
}
|
|
81
|
+
if (deltab > 0) {
|
|
82
|
+
return scrollBy(deltab < deltat ? deltat : deltab);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
63
85
|
var getLastVisibleElement = function (deltaY = 0) {
|
|
64
86
|
var { scrollTop } = list;
|
|
65
87
|
scrollTop += deltaY;
|
|
@@ -85,6 +107,7 @@ function ylist(container, generator, $Y) {
|
|
|
85
107
|
return map;
|
|
86
108
|
};
|
|
87
109
|
var createItem = function (index) {
|
|
110
|
+
console.log(index)
|
|
88
111
|
var item = generator(index);
|
|
89
112
|
if (item) {
|
|
90
113
|
item.index = index;
|
|
@@ -102,10 +125,10 @@ function ylist(container, generator, $Y) {
|
|
|
102
125
|
}
|
|
103
126
|
var cache_height = list.offsetHeight;
|
|
104
127
|
var index = itemIndex | 0;
|
|
128
|
+
if (itemIndex < 0) index--;
|
|
105
129
|
var ratio = itemIndex - index || 0;
|
|
106
|
-
if (index < 0) index = 0;
|
|
107
130
|
var childrenMap = getChildrenMap();
|
|
108
|
-
var offsetBottom = 0, ratioTop = 0, offset =
|
|
131
|
+
var offsetBottom = 0, ratioTop = 0, offset = index, last_item = getFirstElement() || null, last_index = last_item && last_item.index || offset;
|
|
109
132
|
var count = 0, delta = 1, bottom_item, offsett = offset, offsetb = offset, top_item;
|
|
110
133
|
var indexed_item;
|
|
111
134
|
while (offsetBottom - ratioTop <= list.clientHeight + cache_height || indexed_item && top_item && indexed_item.offsetTop - top_item.offsetTop < cache_height) {
|
|
@@ -181,7 +204,9 @@ function ylist(container, generator, $Y) {
|
|
|
181
204
|
var currentY = function () {
|
|
182
205
|
var firstElement = getFirstElement(1);
|
|
183
206
|
if (!firstElement) return;
|
|
184
|
-
|
|
207
|
+
var index = firstElement.index;
|
|
208
|
+
if (index < 0) index = index - index | 0;
|
|
209
|
+
return index * firstElement.offsetHeight + list.scrollTop;
|
|
185
210
|
};
|
|
186
211
|
var getBottomElement = function (last_element) {
|
|
187
212
|
if (!last_element) return null;
|
|
@@ -237,8 +262,6 @@ function ylist(container, generator, $Y) {
|
|
|
237
262
|
let item = childrenMap[k];
|
|
238
263
|
if (item.offsetTop + getOffsetHeight(item) + cache_height < scrollTop) {
|
|
239
264
|
collection.push(item);
|
|
240
|
-
} else {
|
|
241
|
-
break;
|
|
242
265
|
}
|
|
243
266
|
}
|
|
244
267
|
if (collection.length) {
|
|
@@ -280,9 +303,6 @@ function ylist(container, generator, $Y) {
|
|
|
280
303
|
if (!(scrollTop < targetHeight)) {
|
|
281
304
|
paddingCount--;
|
|
282
305
|
}
|
|
283
|
-
if (!(offset >= 0)) {
|
|
284
|
-
break;
|
|
285
|
-
}
|
|
286
306
|
var item = childrenMap[offset];
|
|
287
307
|
if (!item) {
|
|
288
308
|
item = createItem(offset);
|
|
@@ -313,7 +333,6 @@ function ylist(container, generator, $Y) {
|
|
|
313
333
|
} else {
|
|
314
334
|
deltaScroll = patchTop(deltaY, animate);
|
|
315
335
|
}
|
|
316
|
-
|
|
317
336
|
if (deltaScroll) {
|
|
318
337
|
if (animate && __scrollBy) {
|
|
319
338
|
list.scrollTop += deltaScroll - deltaY;
|
|
@@ -378,13 +397,20 @@ function ylist(container, generator, $Y) {
|
|
|
378
397
|
};
|
|
379
398
|
if (!/^i(Phone|Pod|Watch|Pad)|^Mac/i.test(navigator.platform)) var __scrollBy = list.scrollBy;
|
|
380
399
|
list.scrollBy = scrollBy;
|
|
381
|
-
list.index = function () {
|
|
400
|
+
list.index = function (update) {
|
|
401
|
+
if (update === false) return saved_itemIndex;
|
|
382
402
|
var firstElement = getFirstVisibleElement();
|
|
383
403
|
if (!firstElement) return saved_itemIndex;
|
|
384
404
|
var index = firstElement.index;
|
|
385
405
|
var scrolled = (list.scrollTop - firstElement.offsetTop + parseFloat(getComputedStyle(list).paddingTop)) / firstElement.offsetHeight;
|
|
386
406
|
return index + scrolled;
|
|
387
407
|
};
|
|
408
|
+
on("remove")(list, function () {
|
|
409
|
+
saved_itemIndex = list.index();
|
|
410
|
+
});
|
|
411
|
+
on("append")(list, function () {
|
|
412
|
+
if (isFinite(saved_itemIndex)) list.go(saved_itemIndex);
|
|
413
|
+
})
|
|
388
414
|
list.topIndex = function () {
|
|
389
415
|
var element = getFirstElement(1);
|
|
390
416
|
return element ? element.index : 0;
|
|
@@ -392,6 +418,7 @@ function ylist(container, generator, $Y) {
|
|
|
392
418
|
list.getIndexedElement = getIndexedElement;
|
|
393
419
|
list.patchBottom = patchBottom;
|
|
394
420
|
list.patchTop = patchTop;
|
|
421
|
+
list.scrollIfNotCover = scrollIfNotCover;
|
|
395
422
|
vbox(list, $Y);
|
|
396
423
|
return list;
|
|
397
424
|
}
|
|
@@ -400,7 +427,7 @@ var xlist = arriswise(ylist, allArgumentsNames.concat([].slice.call(arguments, 0
|
|
|
400
427
|
|
|
401
428
|
var getGeneratorFromArray = function (source) {
|
|
402
429
|
return function (index) {
|
|
403
|
-
if (index >= source.length) return null;
|
|
430
|
+
if (index >= source.length || index < 0) return null;
|
|
404
431
|
return block(source[index]);
|
|
405
432
|
};
|
|
406
433
|
};
|
package/coms/zimoli/list_test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var listX = list(function (index) {
|
|
2
|
-
if(index>100)return;
|
|
2
|
+
if (index > 100 || index < 0) return;
|
|
3
3
|
var item = div();
|
|
4
4
|
css(item, `height:100%;width:${Math.random() * 110 + 30}px;border:1px solid;`);
|
|
5
5
|
text(item, index);
|
|
@@ -10,7 +10,7 @@ onappend(listX, function () {
|
|
|
10
10
|
});
|
|
11
11
|
css(listX, "width:360px;height:160px;");
|
|
12
12
|
var listY = list(function (index) {
|
|
13
|
-
if(index>100)return;
|
|
13
|
+
if (index > 100 || index < 0) return;
|
|
14
14
|
var item = div();
|
|
15
15
|
css(item, `width:100%;height:${Math.random() * 110 + 30}px;border:1px solid;`);
|
|
16
16
|
text(item, index);
|
package/coms/zimoli/menu.js
CHANGED
package/coms/zimoli/menuList.js
CHANGED
|
@@ -113,7 +113,7 @@ function keytab(event) {
|
|
|
113
113
|
if (root_menu !== document.activeElement) return;
|
|
114
114
|
var menu = mounted_menus[mounted_menus.length - 1] || root_menu;
|
|
115
115
|
event.preventDefault();
|
|
116
|
-
menu.moveFocus(1);
|
|
116
|
+
menu.moveFocus(event.shiftKey ? -1 : 1);
|
|
117
117
|
}
|
|
118
118
|
function keyesc() {
|
|
119
119
|
if (root_menu === document.activeElement && !mounted_menus.length) {
|
|
@@ -142,17 +142,16 @@ function keyspace() {
|
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
function register() {
|
|
145
|
-
// on('keydown.alt')(window, e => e.preventDefault());
|
|
146
|
-
on('keydown.tab')(window, keytab);
|
|
147
|
-
on('keydown.alt.')(window, keyalt);
|
|
148
|
-
on('keydown.esc')(window, keyesc);
|
|
149
|
-
on('keydown.left')(window, keyleft);
|
|
150
|
-
on('keydown.right')(window, keyright);
|
|
151
|
-
on('keydown.up')(window, keyup);
|
|
152
|
-
on('keydown.down')(window, keydown);
|
|
153
|
-
on('keydown.enter')(window, keyspace);
|
|
154
|
-
on('keydown.space')(window, keyspace);
|
|
155
145
|
root_menu = this;
|
|
146
|
+
bind('keydown.tab')(root_menu, keytab);
|
|
147
|
+
bind('keydown.alt.')(root_menu, keyalt);
|
|
148
|
+
bind('keydown.esc')(root_menu, keyesc);
|
|
149
|
+
bind('keydown.left')(root_menu, keyleft);
|
|
150
|
+
bind('keydown.right')(root_menu, keyright);
|
|
151
|
+
bind('keydown.up')(root_menu, keyup);
|
|
152
|
+
bind('keydown.down')(root_menu, keydown);
|
|
153
|
+
bind('keydown.enter')(root_menu, keyspace);
|
|
154
|
+
bind('keydown.space')(root_menu, keyspace);
|
|
156
155
|
}
|
|
157
156
|
function main(page, items, active, direction = 'y') {
|
|
158
157
|
if (!isNode(page)) {
|
|
@@ -208,8 +207,8 @@ function main(page, items, active, direction = 'y') {
|
|
|
208
207
|
var open = function () {
|
|
209
208
|
cancel();
|
|
210
209
|
var elem = this;
|
|
211
|
-
page.setFocus(elem);
|
|
212
210
|
if (page.ispop) popTimer = setTimeout(function () {
|
|
211
|
+
page.setFocus(elem);
|
|
213
212
|
popMenu(elem.menu, elem);
|
|
214
213
|
}, 60);
|
|
215
214
|
};
|
|
@@ -261,6 +260,7 @@ function main(page, items, active, direction = 'y') {
|
|
|
261
260
|
if (!page.firstMenu) {
|
|
262
261
|
page.firstMenu = a;
|
|
263
262
|
}
|
|
263
|
+
a.menu = s.menu;
|
|
264
264
|
return a;
|
|
265
265
|
},
|
|
266
266
|
menus: items,
|
package/coms/zimoli/on.js
CHANGED
package/coms/zimoli/select.js
CHANGED
|
@@ -94,6 +94,15 @@ function select(target, list, removeOnSelect, direction) {
|
|
|
94
94
|
if (removeOnSelect === null) {
|
|
95
95
|
onmousedown(list, preventDefault);
|
|
96
96
|
}
|
|
97
|
+
on("keydown.up")(target, preventDefault);
|
|
98
|
+
on("keydown.down")(target, preventDefault);
|
|
99
|
+
on("keydown.enter")(target, preventDefault);
|
|
100
|
+
on("keydown.space")(target, preventDefault);
|
|
101
|
+
var pop = function () {
|
|
102
|
+
if (saved_list !== list) mousedown.call(this);
|
|
103
|
+
};
|
|
104
|
+
on("keydown.down")(target, pop);
|
|
105
|
+
on("keydown.enter")(target, pop);
|
|
97
106
|
onremove(list, onlistremove);
|
|
98
107
|
};
|
|
99
108
|
if (isNode(list)) {
|
|
@@ -103,7 +112,23 @@ function select(target, list, removeOnSelect, direction) {
|
|
|
103
112
|
};
|
|
104
113
|
var setIcon = function () {
|
|
105
114
|
};
|
|
106
|
-
}
|
|
115
|
+
}
|
|
116
|
+
else if (target.$src) {
|
|
117
|
+
var generator = getGenerator(target);
|
|
118
|
+
var initList2 = function (src) {
|
|
119
|
+
list = selectList(generator, src, target.multiple, target.editable);
|
|
120
|
+
if (!target.multiple) {
|
|
121
|
+
onclick(list, onlistclick);
|
|
122
|
+
}
|
|
123
|
+
bindEvent();
|
|
124
|
+
};
|
|
125
|
+
care(target, initList2);
|
|
126
|
+
var initList = function () {
|
|
127
|
+
};
|
|
128
|
+
var setIcon = function () {
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
107
132
|
var savedOptions;
|
|
108
133
|
removeOnSelect = null;
|
|
109
134
|
var lastSelected = [];
|
|
@@ -29,8 +29,28 @@ var multipleClick = function () {
|
|
|
29
29
|
dispatch(node, "change");
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
|
|
33
|
+
function main() {
|
|
34
|
+
var children, multiple, addable, generator, page;
|
|
35
|
+
for (let a of arguments) {
|
|
36
|
+
if (a instanceof Array) children = a;
|
|
37
|
+
switch (typeof a) {
|
|
38
|
+
case "function":
|
|
39
|
+
generator = a;
|
|
40
|
+
break;
|
|
41
|
+
case "boolean":
|
|
42
|
+
if (multiple === void 0) multiple = a;
|
|
43
|
+
else addable = a;
|
|
44
|
+
case "object":
|
|
45
|
+
if (isNode(a)) {
|
|
46
|
+
page = a;
|
|
47
|
+
if (!generator) generator = getGenerator(page);
|
|
48
|
+
}
|
|
49
|
+
else if (a.length) children = a;
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (!page) page = div();
|
|
34
54
|
page.value = multiple ? [] : "";
|
|
35
55
|
var clicker = multiple ? multipleClick : singleClick;
|
|
36
56
|
var itemMap = Object.create(null);
|
|
@@ -67,18 +87,28 @@ function main(children, multiple, addable) {
|
|
|
67
87
|
item.setAttribute('disabled', '');
|
|
68
88
|
} else {
|
|
69
89
|
onclick(item, clicker);
|
|
90
|
+
on("mouseenter")(item, mouseenter);
|
|
70
91
|
}
|
|
71
92
|
return item;
|
|
72
93
|
|
|
73
94
|
}
|
|
95
|
+
var mouseenter = function () {
|
|
96
|
+
if (!mouse) return;
|
|
97
|
+
focus = this.index;
|
|
98
|
+
setFocus();
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
|
|
74
102
|
var hasIcon = false, iconed = '';
|
|
75
103
|
var page = list(page, function (i) {
|
|
76
104
|
if (i < 0 || i >= children.length) return;
|
|
77
|
-
return createItem(children[i]);
|
|
105
|
+
return createItem(generator ? generator(i) : children[i]);
|
|
78
106
|
});
|
|
79
|
-
|
|
107
|
+
once("append")(page, function () {
|
|
108
|
+
var index = 0;
|
|
109
|
+
for (var cx = 0, dx = children.length; cx < dx; cx++)if (children[cx].selected) index = cx;
|
|
80
110
|
page.clean();
|
|
81
|
-
page.go(
|
|
111
|
+
page.go(index);
|
|
82
112
|
if (adder) {
|
|
83
113
|
remove(adder);
|
|
84
114
|
appendChild(page, adder);
|
|
@@ -135,6 +165,60 @@ function main(children, multiple, addable) {
|
|
|
135
165
|
adder.setAttribute("adder", '');
|
|
136
166
|
}
|
|
137
167
|
page.icon = iconed;
|
|
168
|
+
var focus = 0, focused, mouse = false;
|
|
169
|
+
var setFocus = function () {
|
|
170
|
+
var e = page.getIndexedElement(focus);
|
|
171
|
+
if (e === focused) return;
|
|
172
|
+
if (focused) removeClass(focused, 'focus');
|
|
173
|
+
focused = e;
|
|
174
|
+
if (e) addClass(e, 'focus');
|
|
175
|
+
mouse = false;
|
|
176
|
+
};
|
|
177
|
+
var setMouse = function () {
|
|
178
|
+
mouse = true;
|
|
179
|
+
}
|
|
180
|
+
onmousemove(page, setMouse);
|
|
181
|
+
onmousewheel(page, setMouse);
|
|
182
|
+
var moveFocus = function (delta) {
|
|
183
|
+
focus += delta;
|
|
184
|
+
if (focus < 0) focus = 0;
|
|
185
|
+
if (focus >= children.length) focus = children.length - 1;
|
|
186
|
+
page.scrollIfNotCover(focus);
|
|
187
|
+
setFocus();
|
|
188
|
+
};
|
|
189
|
+
bind('keydown.up')(page, function () {
|
|
190
|
+
moveFocus(-1);
|
|
191
|
+
});
|
|
192
|
+
bind('keydown.down')(page, function () {
|
|
193
|
+
moveFocus(1);
|
|
194
|
+
});
|
|
195
|
+
bind('keydown.tab')(page, function (event) {
|
|
196
|
+
if (document.activeElement === page.target) event.preventDefault();
|
|
197
|
+
moveFocus(event.shiftKey ? -1 : 1);
|
|
198
|
+
});
|
|
199
|
+
bind("keydown.home")(page, function (e) {
|
|
200
|
+
moveFocus(-focus);
|
|
201
|
+
});
|
|
202
|
+
bind("keydown.end")(page, function (e) {
|
|
203
|
+
moveFocus(children.length - 1 - focus);
|
|
204
|
+
});
|
|
205
|
+
bind("keydown.pagedown")(page, function (e) {
|
|
206
|
+
page.scrollBy(page.clientHeight);
|
|
207
|
+
focus = page.index() | 0;
|
|
208
|
+
moveFocus(0);
|
|
209
|
+
})
|
|
210
|
+
bind("keydown.pageup")(page, function (e) {
|
|
211
|
+
page.scrollBy(-page.clientHeight);
|
|
212
|
+
focus = page.index() | 0;
|
|
213
|
+
moveFocus(0);
|
|
214
|
+
})
|
|
215
|
+
var enter = function (e) {
|
|
216
|
+
e.preventDefault();
|
|
217
|
+
var e = page.getIndexedElement(focus);
|
|
218
|
+
if (e) e.click();
|
|
219
|
+
};
|
|
220
|
+
bind('keydown.enter')(page, enter);
|
|
221
|
+
bind('keydown.space')(page, enter);
|
|
138
222
|
on('mousedown')(page, e => e.preventDefault());
|
|
139
223
|
return page;
|
|
140
224
|
}
|
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
<option>选项一</option>
|
|
3
3
|
<option>选项二</option>
|
|
4
4
|
<option>选项三</option>
|
|
5
|
+
<option selected>简单选项</option>
|
|
5
6
|
</select>
|
|
6
7
|
<select>
|
|
7
|
-
<option
|
|
8
|
-
<option
|
|
9
|
-
<option>选项三</option>
|
|
8
|
+
<option -repeat="(o,i) in options600" -text="'选项'+o">选项</option>
|
|
9
|
+
<option selected>600个选项</option>
|
|
10
10
|
</select>
|
|
11
|
+
<select -src="(o,i) in options6000">
|
|
12
|
+
<option -text="'选项'+o">选项</option>
|
|
13
|
+
<option insert selected>60000个选项</option>
|
|
14
|
+
</select>
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
var page = div();
|
|
2
2
|
page.innerHTML = selectList_test;
|
|
3
|
-
render(page,{
|
|
4
|
-
select
|
|
5
|
-
|
|
3
|
+
render(page, {
|
|
4
|
+
select,
|
|
5
|
+
select2() {
|
|
6
|
+
var sel = document.createElement("select");
|
|
7
|
+
return sel;
|
|
8
|
+
},
|
|
9
|
+
options600: new Array(600).fill(0).map((_, a) => a),
|
|
10
|
+
options6000: new Array(60000).fill(0).map((_, a) => a)
|
|
11
|
+
});
|
|
6
12
|
function main() {
|
|
7
13
|
return page;
|
|
8
14
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var listY = list(function (
|
|
1
|
+
var listY = list(function (index) {
|
|
2
2
|
var item = div();
|
|
3
3
|
css(item, `width:100%;height:${Math.random() * 110 + 30}px;border:1px solid;`);
|
|
4
|
-
text(item,
|
|
4
|
+
text(item, index);
|
|
5
5
|
return item;
|
|
6
6
|
}, "Y");
|
|
7
7
|
onappend(listY, function () {
|