efront 3.11.4 → 3.12.3
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/pivot/link/list.html +1 -1
- package/apps/pivot/link/list.js +2 -2
- package/coms/basic/sortname.js +6 -2
- package/coms/zimoli/active.js +4 -4
- package/coms/zimoli/button.js +19 -1
- package/coms/zimoli/button.less +7 -0
- package/coms/zimoli/chooseFile.js +3 -1
- package/coms/zimoli/data.js +2 -1
- package/coms/zimoli/encode62.js +6 -3
- package/coms/zimoli/getGenerator.js +3 -3
- package/coms/zimoli/list.js +38 -12
- package/coms/zimoli/list_test.js +2 -2
- package/coms/zimoli/menu.js +14 -3
- package/coms/zimoli/menuList.js +12 -13
- package/coms/zimoli/model.js +5 -3
- package/coms/zimoli/on.js +2 -2
- package/coms/zimoli/picture.js +9 -3
- package/coms/zimoli/popup.js +4 -4
- package/coms/zimoli/render.js +1 -1
- 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/package.json +1 -1
- package/public/efront.js +1 -1
- package/readme.md +7 -0
|
@@ -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 () {
|