efront 3.11.2 → 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/apps/kugou/api.js +10 -7
- package/apps/pivot/link/list.html +1 -1
- package/apps/pivot/link/list.js +2 -2
- package/coms/basic/parseYML.js +1 -1
- package/coms/basic/sortname.js +6 -2
- package/coms/frame/route.js +28 -3
- package/coms/kugou/parseSongsList.js +24 -10
- package/coms/zimoli/Item.js +1 -0
- package/coms/zimoli/button.less +3 -2
- package/coms/zimoli/getGenerator.js +22 -19
- package/coms/zimoli/list.js +38 -11
- package/coms/zimoli/list_test.js +2 -2
- package/coms/zimoli/menu.js +4 -2
- package/coms/zimoli/menu.less +49 -80
- package/coms/zimoli/menuItem.js +2 -0
- package/coms/zimoli/menuItem.less +16 -0
- package/coms/zimoli/menuList.js +33 -31
- package/coms/zimoli/menuList.less +6 -2
- package/coms/zimoli/model.js +5 -3
- package/coms/zimoli/on.js +2 -2
- package/coms/zimoli/render.js +14 -12
- package/coms/zimoli/select.js +26 -1
- package/coms/zimoli/selectList.js +99 -9
- package/coms/zimoli/selectList.less +2 -2
- 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/coms/zimoli/tree.js +7 -5
- package/coms/zimoli/tree.less +14 -1
- package/package.json +1 -1
- package/public/efront.js +1 -1
- package/readme.md +7 -0
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
i{
|
|
2
2
|
display: inline-block;
|
|
3
3
|
width: 1em;
|
|
4
|
+
}
|
|
5
|
+
&.line,
|
|
6
|
+
&[line] {
|
|
7
|
+
box-shadow: none;
|
|
8
|
+
>.track{
|
|
9
|
+
display: none;
|
|
10
|
+
}
|
|
11
|
+
line-height: 0;
|
|
12
|
+
font-size: 0;
|
|
13
|
+
&:after {
|
|
14
|
+
content: "";
|
|
15
|
+
display: block;
|
|
16
|
+
border-bottom: 1px solid;
|
|
17
|
+
opacity: .36;
|
|
18
|
+
margin: 0 -20px;
|
|
19
|
+
}
|
|
4
20
|
}
|
package/coms/zimoli/menuList.js
CHANGED
|
@@ -11,11 +11,11 @@ var clear = function () {
|
|
|
11
11
|
var unfocus = function () {
|
|
12
12
|
remove(mounted_menus);
|
|
13
13
|
this.ispop = false;
|
|
14
|
-
this.setFocus();
|
|
14
|
+
this.setFocus(null);
|
|
15
15
|
};
|
|
16
|
-
var setFocus = function (focused
|
|
16
|
+
var setFocus = function (focused) {
|
|
17
17
|
var page = this;
|
|
18
|
-
if (
|
|
18
|
+
if (focused) {
|
|
19
19
|
if (page.focused !== focused) {
|
|
20
20
|
if (page.focused) removeClass(page.focused, 'focus');
|
|
21
21
|
if (focused) addClass(focused, "focus");
|
|
@@ -106,12 +106,18 @@ function keyalt() {
|
|
|
106
106
|
else {
|
|
107
107
|
root_menu.tabIndex = 0;
|
|
108
108
|
root_menu.focus();
|
|
109
|
+
root_menu.setFocus(this.firstMenu);
|
|
109
110
|
}
|
|
110
|
-
|
|
111
|
+
}
|
|
112
|
+
function keytab(event) {
|
|
113
|
+
if (root_menu !== document.activeElement) return;
|
|
114
|
+
var menu = mounted_menus[mounted_menus.length - 1] || root_menu;
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
menu.moveFocus(event.shiftKey ? -1 : 1);
|
|
111
117
|
}
|
|
112
118
|
function keyesc() {
|
|
113
119
|
if (root_menu === document.activeElement && !mounted_menus.length) {
|
|
114
|
-
if (!root_menu.ispop) root_menu.blur()
|
|
120
|
+
if (!root_menu.ispop) root_menu.blur();
|
|
115
121
|
else root_menu.ispop = false;
|
|
116
122
|
}
|
|
117
123
|
}
|
|
@@ -136,16 +142,16 @@ function keyspace() {
|
|
|
136
142
|
}
|
|
137
143
|
}
|
|
138
144
|
function register() {
|
|
139
|
-
// on('keydown.alt')(window, e => e.preventDefault());
|
|
140
|
-
on('keydown.alt.')(window, keyalt);
|
|
141
|
-
on('keydown.esc')(window, keyesc);
|
|
142
|
-
on('keydown.left')(window, keyleft);
|
|
143
|
-
on('keydown.right')(window, keyright);
|
|
144
|
-
on('keydown.up')(window, keyup);
|
|
145
|
-
on('keydown.down')(window, keydown);
|
|
146
|
-
on('keydown.enter')(window, keyspace);
|
|
147
|
-
on('keydown.space')(window, keyspace);
|
|
148
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);
|
|
149
155
|
}
|
|
150
156
|
function main(page, items, active, direction = 'y') {
|
|
151
157
|
if (!isNode(page)) {
|
|
@@ -162,6 +168,7 @@ function main(page, items, active, direction = 'y') {
|
|
|
162
168
|
if (!item.children || !item.children.length) return;
|
|
163
169
|
var clone = template.cloneNode();
|
|
164
170
|
clone.$parentScopes = page.$parentScopes;
|
|
171
|
+
clone.$scope = page.$scope;
|
|
165
172
|
clone.$src = src;
|
|
166
173
|
clone.innerHTML = template.innerHTML;
|
|
167
174
|
var menu = main(clone, item.children, active);
|
|
@@ -200,8 +207,8 @@ function main(page, items, active, direction = 'y') {
|
|
|
200
207
|
var open = function () {
|
|
201
208
|
cancel();
|
|
202
209
|
var elem = this;
|
|
203
|
-
page.setFocus(elem);
|
|
204
210
|
if (page.ispop) popTimer = setTimeout(function () {
|
|
211
|
+
page.setFocus(elem);
|
|
205
212
|
popMenu(elem.menu, elem);
|
|
206
213
|
}, 60);
|
|
207
214
|
};
|
|
@@ -210,16 +217,18 @@ function main(page, items, active, direction = 'y') {
|
|
|
210
217
|
}
|
|
211
218
|
var fire = function () {
|
|
212
219
|
cancel();
|
|
220
|
+
if (this.menu.line) return;
|
|
213
221
|
var pop = active(this.menu, this);
|
|
214
222
|
if (pop === false) return;
|
|
215
223
|
var root = page.root || page;
|
|
216
224
|
if (root.ispop === 1) root.ispop = false;
|
|
217
225
|
if (page.actived && page.actived.target === this) {
|
|
226
|
+
while (mounted_menus.length && mounted_menus[mounted_menus.length - 1] !== page.actived) remove(mounted_menus.pop());
|
|
218
227
|
if (!mounted_menus.length) {
|
|
219
228
|
popMenu(this.menu, this);
|
|
220
229
|
}
|
|
221
230
|
else {
|
|
222
|
-
|
|
231
|
+
remove(mounted_menus.pop());
|
|
223
232
|
}
|
|
224
233
|
}
|
|
225
234
|
else {
|
|
@@ -244,13 +253,14 @@ function main(page, items, active, direction = 'y') {
|
|
|
244
253
|
return false;
|
|
245
254
|
};
|
|
246
255
|
var $scope = {
|
|
247
|
-
"menu-item"
|
|
248
|
-
var a =
|
|
256
|
+
"menu-item"(e, s) {
|
|
257
|
+
var a = button(
|
|
249
258
|
menuItem(e, s, this.hasIcon)
|
|
250
259
|
);
|
|
251
260
|
if (!page.firstMenu) {
|
|
252
261
|
page.firstMenu = a;
|
|
253
262
|
}
|
|
263
|
+
a.menu = s.menu;
|
|
254
264
|
return a;
|
|
255
265
|
},
|
|
256
266
|
menus: items,
|
|
@@ -261,31 +271,23 @@ function main(page, items, active, direction = 'y') {
|
|
|
261
271
|
};
|
|
262
272
|
if (page.$src) {
|
|
263
273
|
var src = page.$src;
|
|
264
|
-
var parentScopes = page.$parentScopes;
|
|
265
274
|
var itemName = src.itemName;
|
|
266
275
|
var className = `{'has-children':${itemName}.children&&${itemName}.children.length,'warn':${itemName}.type==='danger'||${itemName}.type==='warn'||${itemName}.type==='red'}`;
|
|
267
276
|
var notHidden = `!${itemName}.hidden`;
|
|
277
|
+
var generator = getGenerator(page, 'menu-item');
|
|
268
278
|
|
|
269
279
|
list(page, function (index) {
|
|
270
280
|
var item = items[index];
|
|
271
281
|
if (!item) return;
|
|
272
|
-
var a = $scope["menu-item"](null, item);
|
|
273
|
-
var scope = {};
|
|
274
282
|
if (item instanceof Item) item = item.value;
|
|
275
|
-
|
|
276
|
-
else scope.$item = item;
|
|
277
|
-
if (src.keyName) scope[src.keyName] = index;
|
|
278
|
-
else scope.$key = index;
|
|
279
|
-
if (src.indexName) scope[src.indexName] = index;
|
|
280
|
-
else scope.$index = index;
|
|
281
|
-
if (src.srcName) scope[src.srcName] = items;
|
|
283
|
+
var a = $scope["menu-item"](null, item);
|
|
282
284
|
if (src.itemName) a.setAttribute("e-if", notHidden);
|
|
285
|
+
a.setAttribute("e-class", className);
|
|
286
|
+
a = generator(index, item, a);
|
|
283
287
|
a.menu = item;
|
|
284
288
|
on("mouseleave")(a, cancel);
|
|
285
289
|
on("mouseenter")(a, open);
|
|
286
290
|
on("click")(a, fire);
|
|
287
|
-
a.setAttribute("e-class", className);
|
|
288
|
-
render(a, scope, parentScopes);
|
|
289
291
|
return a;
|
|
290
292
|
});
|
|
291
293
|
on("append")(page, function () {
|
|
@@ -303,7 +305,7 @@ function main(page, items, active, direction = 'y') {
|
|
|
303
305
|
});
|
|
304
306
|
}
|
|
305
307
|
else {
|
|
306
|
-
var generator = getGenerator(page);
|
|
308
|
+
var generator = getGenerator(page, 'menu-item');
|
|
307
309
|
|
|
308
310
|
list(page, function (index) {
|
|
309
311
|
var elem = generator(index);
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
background-color: #fff;
|
|
6
6
|
box-shadow: 0 0 20px -6px rgba(0, 0, 0, .1);
|
|
7
7
|
border: 1px solid #0003;
|
|
8
|
-
line-height: 28px;
|
|
9
8
|
padding: 6px 0;
|
|
10
9
|
|
|
11
10
|
>menu-item {
|
|
@@ -17,6 +16,10 @@
|
|
|
17
16
|
color: inherit;
|
|
18
17
|
box-shadow: none;
|
|
19
18
|
text-align: inherit;
|
|
19
|
+
vertical-align: top;
|
|
20
|
+
line-height: 20px;
|
|
21
|
+
padding-top: 4px;
|
|
22
|
+
padding-bottom: 4px;
|
|
20
23
|
|
|
21
24
|
&.warn {
|
|
22
25
|
color: #c28;
|
|
@@ -27,7 +30,8 @@
|
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
&.has-children {
|
|
30
|
-
padding:
|
|
33
|
+
padding-right: 24px;
|
|
34
|
+
padding-left: 16px;
|
|
31
35
|
|
|
32
36
|
&:after {
|
|
33
37
|
content: ">";
|
package/coms/zimoli/model.js
CHANGED
|
@@ -91,15 +91,17 @@ var constructors = {
|
|
|
91
91
|
}
|
|
92
92
|
else if (t === 'a') {
|
|
93
93
|
var { field, data } = _;
|
|
94
|
-
var pad = selectList(field.options, field.multi, true);
|
|
95
|
-
var e = document.createElement('select');
|
|
96
94
|
var opt = null;
|
|
97
|
-
for (var
|
|
95
|
+
for (var cx = 0, options = field.options, dx = options.length; cx < dx; cx++) {
|
|
96
|
+
var o = options[cx];
|
|
98
97
|
if (o.key === data[field.key]) {
|
|
99
98
|
opt = o;
|
|
99
|
+
o.selected = true;
|
|
100
100
|
break;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
+
var pad = selectList(field.options, field.multi, true);
|
|
104
|
+
var e = document.createElement('select');
|
|
103
105
|
e.innerHTML = `<option selected value="${opt ? opt.key : ''}">${opt ? opt.name : '请选择'}</option>`;
|
|
104
106
|
e.value = opt ? opt.key : '';
|
|
105
107
|
elem = select(e, pad);
|
package/coms/zimoli/on.js
CHANGED
package/coms/zimoli/render.js
CHANGED
|
@@ -529,14 +529,14 @@ var binders = {
|
|
|
529
529
|
};
|
|
530
530
|
var createEmiter = function (on) {
|
|
531
531
|
return function (key, search) {
|
|
532
|
-
|
|
533
|
-
|
|
532
|
+
var parsedSrc = this.$src;
|
|
533
|
+
var getter0 = createGetter(search, false), getter1;
|
|
534
|
+
if (parsedSrc) {
|
|
534
535
|
var scopes = this.$parentScopes;
|
|
535
536
|
search = search.slice();
|
|
536
537
|
search[0] += `with(this.$parentScopes[${scopes.length}])`;
|
|
537
|
-
|
|
538
|
+
getter1 = createGetter(search, false);
|
|
538
539
|
}
|
|
539
|
-
var getter = createGetter(search, false);
|
|
540
540
|
on(key)(this, function (e) {
|
|
541
541
|
if (parsedSrc) {
|
|
542
542
|
var target = e.currentTarget || e.target;
|
|
@@ -556,12 +556,14 @@ var createEmiter = function (on) {
|
|
|
556
556
|
var res;
|
|
557
557
|
if (scope) {
|
|
558
558
|
var temp = this.$scope;
|
|
559
|
+
this.$parentScopes.push(temp);
|
|
559
560
|
this.$scope = scope;
|
|
560
|
-
res =
|
|
561
|
+
res = getter1.call(this, e);
|
|
562
|
+
this.$parentScopes.pop();
|
|
561
563
|
this.$scope = temp;
|
|
562
564
|
}
|
|
563
565
|
else {
|
|
564
|
-
res =
|
|
566
|
+
res = getter0.call(this, e);
|
|
565
567
|
}
|
|
566
568
|
if (res && isFunction(res.then)) res.then(digest, digest);
|
|
567
569
|
digest();
|
|
@@ -581,7 +583,7 @@ function getFromScopes(key, scope, parentScopes) {
|
|
|
581
583
|
}
|
|
582
584
|
if (parentScopes) for (var cx = parentScopes.length - 1; cx >= 0; cx--) {
|
|
583
585
|
var o = parentScopes[cx];
|
|
584
|
-
if (key in o) {
|
|
586
|
+
if (o && key in o) {
|
|
585
587
|
return o[key];
|
|
586
588
|
}
|
|
587
589
|
}
|
|
@@ -614,13 +616,13 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
|
|
|
614
616
|
return element;
|
|
615
617
|
}
|
|
616
618
|
var isFirstRender = !element.renderid;
|
|
617
|
-
element.renderid = 1;
|
|
618
|
-
var parentNode = element.parentNode;
|
|
619
|
-
if (parentNode) {
|
|
620
|
-
if (parentNode.renderid > 1 || parentNode.isMounted) element.renderid = 2;
|
|
621
|
-
}
|
|
622
619
|
|
|
623
620
|
if (isFirstRender) {
|
|
621
|
+
element.renderid = 1;
|
|
622
|
+
var parentNode = element.parentNode;
|
|
623
|
+
if (parentNode) {
|
|
624
|
+
if (parentNode.renderid > 1 || parentNode.isMounted) element.renderid = 2;
|
|
625
|
+
}
|
|
624
626
|
element.renders = element.renders ? [].concat(element.renders) : [];
|
|
625
627
|
var { ons, copys, attrs, props, binds, context: withContext } = element.$struct;
|
|
626
628
|
delete element.$struct;
|
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 = [];
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
var singleClick = function () {
|
|
2
2
|
var node = this.parentNode;
|
|
3
3
|
if (node.activeNode === this) return;
|
|
4
|
-
if (node.activeNode)
|
|
4
|
+
if (node.activeNode) {
|
|
5
|
+
if (node.activeNode.origin) node.activeNode.origin.selected = false;
|
|
6
|
+
node.activeNode.removeAttribute("selected");
|
|
7
|
+
}
|
|
5
8
|
this.setAttribute("selected", "");
|
|
9
|
+
|
|
6
10
|
node.activeNode = this;
|
|
7
11
|
if (node.value === this.value) return;
|
|
8
12
|
node.value = this.value;
|
|
9
13
|
node.name = this.name;
|
|
14
|
+
if (this.origin) this.origin.selected = true;
|
|
10
15
|
dispatch(node, "change");
|
|
11
16
|
};
|
|
12
17
|
var multipleClick = function () {
|
|
@@ -20,13 +25,33 @@ var multipleClick = function () {
|
|
|
20
25
|
values.splice(index, 1);
|
|
21
26
|
this.removeAttribute("selected");
|
|
22
27
|
}
|
|
28
|
+
if (this.origin) this.origin.selected = true;
|
|
23
29
|
dispatch(node, "change");
|
|
24
30
|
};
|
|
25
31
|
|
|
26
|
-
|
|
27
|
-
|
|
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();
|
|
28
54
|
page.value = multiple ? [] : "";
|
|
29
|
-
var firstValue = false;
|
|
30
55
|
var clicker = multiple ? multipleClick : singleClick;
|
|
31
56
|
var itemMap = Object.create(null);
|
|
32
57
|
function createItem(option) {
|
|
@@ -36,6 +61,7 @@ function main(children, multiple, addable) {
|
|
|
36
61
|
item.setAttribute("item", '');
|
|
37
62
|
item.innerHTML = option.innerHTML || option.name;
|
|
38
63
|
item.name = option.name || option.innerHTML;
|
|
64
|
+
item.origin = option;
|
|
39
65
|
var icon = option.getAttribute ? option.getAttribute("icon") : option.icon;
|
|
40
66
|
if (icon) {
|
|
41
67
|
if (!hasIcon) {
|
|
@@ -50,10 +76,10 @@ function main(children, multiple, addable) {
|
|
|
50
76
|
if (multiple) {
|
|
51
77
|
item.setAttribute("selected", "");
|
|
52
78
|
page.value.push(option.value);
|
|
53
|
-
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
54
81
|
item.setAttribute("selected", "");
|
|
55
82
|
page.activeNode = item;
|
|
56
|
-
firstValue = true;
|
|
57
83
|
page.value = option.value
|
|
58
84
|
}
|
|
59
85
|
}
|
|
@@ -61,18 +87,28 @@ function main(children, multiple, addable) {
|
|
|
61
87
|
item.setAttribute('disabled', '');
|
|
62
88
|
} else {
|
|
63
89
|
onclick(item, clicker);
|
|
90
|
+
on("mouseenter")(item, mouseenter);
|
|
64
91
|
}
|
|
65
92
|
return item;
|
|
66
93
|
|
|
67
94
|
}
|
|
95
|
+
var mouseenter = function () {
|
|
96
|
+
if (!mouse) return;
|
|
97
|
+
focus = this.index;
|
|
98
|
+
setFocus();
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
|
|
68
102
|
var hasIcon = false, iconed = '';
|
|
69
103
|
var page = list(page, function (i) {
|
|
70
104
|
if (i < 0 || i >= children.length) return;
|
|
71
|
-
return createItem(children[i]);
|
|
105
|
+
return createItem(generator ? generator(i) : children[i]);
|
|
72
106
|
});
|
|
73
|
-
|
|
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;
|
|
74
110
|
page.clean();
|
|
75
|
-
page.go(
|
|
111
|
+
page.go(index);
|
|
76
112
|
if (adder) {
|
|
77
113
|
remove(adder);
|
|
78
114
|
appendChild(page, adder);
|
|
@@ -129,6 +165,60 @@ function main(children, multiple, addable) {
|
|
|
129
165
|
adder.setAttribute("adder", '');
|
|
130
166
|
}
|
|
131
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);
|
|
132
222
|
on('mousedown')(page, e => e.preventDefault());
|
|
133
223
|
return page;
|
|
134
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 () {
|
package/coms/zimoli/tree.js
CHANGED
|
@@ -132,16 +132,18 @@ function tree() {
|
|
|
132
132
|
}
|
|
133
133
|
var tabs = new Array(com.tab + 1).join("<t></t>");
|
|
134
134
|
if (isFunction(generator)) {
|
|
135
|
-
var elem = generator(index, com);
|
|
135
|
+
var elem = generator(index, com instanceof Item ? com.value : com);
|
|
136
136
|
if (!elem) return;
|
|
137
|
-
span = document.createElement('
|
|
137
|
+
span = document.createElement('span');
|
|
138
138
|
span.innerHTML = tabs;
|
|
139
|
-
|
|
139
|
+
elem.insertBefore(span, elem.firstChild);
|
|
140
|
+
span = elem;
|
|
140
141
|
} else {
|
|
141
|
-
span =
|
|
142
|
+
span = document.createElement("node");
|
|
142
143
|
html(span, `${tabs}<c>${com.name}</c>${com.test ? "<i>_test</i>" : ""}<a class=count>${com.count}</a>`);
|
|
143
144
|
}
|
|
144
145
|
var _div = button(span);
|
|
146
|
+
_div.setAttribute("node", '');
|
|
145
147
|
_div.index = index;
|
|
146
148
|
|
|
147
149
|
if (!com.saved) {
|
|
@@ -222,7 +224,7 @@ function tree() {
|
|
|
222
224
|
_div.refresh();
|
|
223
225
|
onclick(_div, function () {
|
|
224
226
|
var isClosed = com.isClosed();
|
|
225
|
-
if (!active(banner, com.value, com)) {
|
|
227
|
+
if (!active(banner, com.value, com, _div)) {
|
|
226
228
|
return;
|
|
227
229
|
}
|
|
228
230
|
if (isClosed === com.isClosed() && com.length) {
|
package/coms/zimoli/tree.less
CHANGED
|
@@ -3,13 +3,26 @@
|
|
|
3
3
|
background: #222d32;
|
|
4
4
|
color: #fff;
|
|
5
5
|
|
|
6
|
-
>
|
|
6
|
+
>[node] {
|
|
7
7
|
display: block;
|
|
8
8
|
text-align: left;
|
|
9
9
|
height: auto;
|
|
10
10
|
background-color: inherit;
|
|
11
11
|
color: inherit;
|
|
12
12
|
padding-right: 10px;
|
|
13
|
+
padding-top: 4px;
|
|
14
|
+
padding-bottom: 4px;
|
|
15
|
+
box-shadow: none;
|
|
16
|
+
|
|
17
|
+
&.line,
|
|
18
|
+
&[line] {
|
|
19
|
+
box-shadow: none;
|
|
20
|
+
line-height: 0;
|
|
21
|
+
|
|
22
|
+
>.track {
|
|
23
|
+
display: none;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
13
26
|
}
|
|
14
27
|
}
|
|
15
28
|
|