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
package/apps/pivot/link/list.js
CHANGED
|
@@ -7,13 +7,13 @@ function main() {
|
|
|
7
7
|
await this.clusters;
|
|
8
8
|
this.active();
|
|
9
9
|
},
|
|
10
|
-
index: data.getInstance("index")
|
|
10
|
+
index: data.getInstance("index"),
|
|
11
11
|
clusters: [],
|
|
12
12
|
filterTime(d) {
|
|
13
13
|
return ((new Date - d) / 1000 | 0) + "秒";
|
|
14
14
|
},
|
|
15
15
|
clients: [],
|
|
16
|
-
active(index = this.index) {
|
|
16
|
+
active(index = this.index.index | 0) {
|
|
17
17
|
data.setInstance('index', { index });
|
|
18
18
|
var clusters = this.clusters;
|
|
19
19
|
if (index >= clusters.length) index = clusters.length - 1;
|
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) {
|
package/coms/zimoli/active.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// 激活 自定义的 active 事件
|
|
2
|
-
function active(target, value, item,
|
|
2
|
+
function active(target, value, item = value, srcElem) {
|
|
3
3
|
var activeEvent = createEvent("active");
|
|
4
4
|
activeEvent.item = item;
|
|
5
5
|
activeEvent.value = value;
|
|
6
|
-
if (
|
|
7
|
-
if (Object.defineProperty) Object.defineProperty(activeEvent, 'currentTarget', { value:
|
|
8
|
-
else activeEvent.currentTarget =
|
|
6
|
+
if (srcElem) {
|
|
7
|
+
if (Object.defineProperty) Object.defineProperty(activeEvent, 'currentTarget', { value: srcElem });
|
|
8
|
+
else activeEvent.currentTarget = srcElem;
|
|
9
9
|
}
|
|
10
10
|
activeEvent = dispatch(target, activeEvent);
|
|
11
11
|
return activeEvent && !activeEvent.defaultPrevented;
|
package/coms/zimoli/button.js
CHANGED
|
@@ -16,7 +16,25 @@ var active = function () {
|
|
|
16
16
|
__addClass(this, "hover active");
|
|
17
17
|
};
|
|
18
18
|
var checkclick = function () {
|
|
19
|
-
if (this.hasAttribute("disabled") || this.disabled || this.hasAttribute("loading") || this.loading || this.hasAttribute("pending") || this.pending)
|
|
19
|
+
if (this.hasAttribute("disabled") || this.disabled || this.hasAttribute("loading") || this.loading || this.hasAttribute("pending") || this.pending) {
|
|
20
|
+
onclick.preventClick = true;
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (this.hasAttribute("confirm") || this.confirm) {
|
|
24
|
+
if (!this.confirm_sign) {
|
|
25
|
+
addClass(this, 'confirm');
|
|
26
|
+
var that = this;
|
|
27
|
+
that.confirm_sign = true;
|
|
28
|
+
setTimeout(function () {
|
|
29
|
+
removeClass(that, "confirm");
|
|
30
|
+
delete that.confirm_sign;
|
|
31
|
+
}, 2000);
|
|
32
|
+
onclick.preventClick = true;
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
delete this.confirm_sign;
|
|
36
|
+
removeClass(this, "confirm");
|
|
37
|
+
}
|
|
20
38
|
};
|
|
21
39
|
var resetactive = function () {
|
|
22
40
|
removeClass(this, "active");
|
package/coms/zimoli/button.less
CHANGED
package/coms/zimoli/data.js
CHANGED
|
@@ -927,6 +927,7 @@ var data = {
|
|
|
927
927
|
setSource(sourceid, value) {
|
|
928
928
|
var rememberWithStorage;
|
|
929
929
|
if (isObject(sourceid)) {
|
|
930
|
+
|
|
930
931
|
this.rebuildInstance(dataSourceMap, sourceid);
|
|
931
932
|
rememberWithStorage = value;
|
|
932
933
|
} else {
|
|
@@ -975,7 +976,7 @@ var data = {
|
|
|
975
976
|
if (key === true || key === false || isEmpty(key)) {
|
|
976
977
|
rememberWithStorage = key;
|
|
977
978
|
key = null;
|
|
978
|
-
var value = instance;
|
|
979
|
+
var value = instance.valueOf();
|
|
979
980
|
} else {
|
|
980
981
|
var value = instance[key];
|
|
981
982
|
}
|
package/coms/zimoli/encode62.js
CHANGED
|
@@ -29,7 +29,9 @@ var encode62 = {
|
|
|
29
29
|
timeencode(string) {
|
|
30
30
|
var { time_delta } = this;
|
|
31
31
|
var time_free = time_delta / 6 | 0;
|
|
32
|
-
var
|
|
32
|
+
var time = +new Date;
|
|
33
|
+
time = time - time % (time_delta >> 2);
|
|
34
|
+
var time_stamp = time - time_free;
|
|
33
35
|
var time_rest = time_stamp % time_delta;
|
|
34
36
|
var time_rest_str = time_rest.toString(36);
|
|
35
37
|
var time_delta_str = time_delta.toString(36);
|
|
@@ -39,9 +41,10 @@ var encode62 = {
|
|
|
39
41
|
timeupdate(string) {
|
|
40
42
|
var { time_delta } = this;
|
|
41
43
|
var time_rest = string.slice(string.length - time_delta.toString(36).length, string.length);
|
|
42
|
-
var
|
|
44
|
+
var time = +new Date;
|
|
45
|
+
var time_start = parseInt((time - parseInt(time_rest, 36)) / time_delta) * time_delta;
|
|
43
46
|
var time_stamp = time_start + parseInt(time_rest, 36);
|
|
44
|
-
if (time_stamp + (time_delta >> 1) >
|
|
47
|
+
if (time_stamp + (time_delta >> 1) > time) {
|
|
45
48
|
return string;
|
|
46
49
|
} else {
|
|
47
50
|
return this.timeencode(this.timedecode(string));
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var _slider = createElement(div);
|
|
3
3
|
var getGenerator = function (container, tagName = 'item') {
|
|
4
4
|
if (!container) return;
|
|
5
|
-
if (
|
|
5
|
+
if (container.$generator) return container.$generator;
|
|
6
6
|
var template = document.createElement(tagName);
|
|
7
7
|
var templates = [].concat.apply([], container.childNodes).filter(a => {
|
|
8
8
|
if (a.hasAttribute('insert')) {
|
|
@@ -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;
|
|
@@ -102,10 +124,10 @@ function ylist(container, generator, $Y) {
|
|
|
102
124
|
}
|
|
103
125
|
var cache_height = list.offsetHeight;
|
|
104
126
|
var index = itemIndex | 0;
|
|
127
|
+
if (itemIndex < 0) index--;
|
|
105
128
|
var ratio = itemIndex - index || 0;
|
|
106
|
-
if (index < 0) index = 0;
|
|
107
129
|
var childrenMap = getChildrenMap();
|
|
108
|
-
var offsetBottom = 0, ratioTop = 0, offset =
|
|
130
|
+
var offsetBottom = 0, ratioTop = 0, offset = index, last_item = getFirstElement() || null, last_index = last_item && last_item.index || offset;
|
|
109
131
|
var count = 0, delta = 1, bottom_item, offsett = offset, offsetb = offset, top_item;
|
|
110
132
|
var indexed_item;
|
|
111
133
|
while (offsetBottom - ratioTop <= list.clientHeight + cache_height || indexed_item && top_item && indexed_item.offsetTop - top_item.offsetTop < cache_height) {
|
|
@@ -181,7 +203,9 @@ function ylist(container, generator, $Y) {
|
|
|
181
203
|
var currentY = function () {
|
|
182
204
|
var firstElement = getFirstElement(1);
|
|
183
205
|
if (!firstElement) return;
|
|
184
|
-
|
|
206
|
+
var index = firstElement.index;
|
|
207
|
+
if (index < 0) index = index - index | 0;
|
|
208
|
+
return index * firstElement.offsetHeight + list.scrollTop;
|
|
185
209
|
};
|
|
186
210
|
var getBottomElement = function (last_element) {
|
|
187
211
|
if (!last_element) return null;
|
|
@@ -237,8 +261,6 @@ function ylist(container, generator, $Y) {
|
|
|
237
261
|
let item = childrenMap[k];
|
|
238
262
|
if (item.offsetTop + getOffsetHeight(item) + cache_height < scrollTop) {
|
|
239
263
|
collection.push(item);
|
|
240
|
-
} else {
|
|
241
|
-
break;
|
|
242
264
|
}
|
|
243
265
|
}
|
|
244
266
|
if (collection.length) {
|
|
@@ -280,9 +302,6 @@ function ylist(container, generator, $Y) {
|
|
|
280
302
|
if (!(scrollTop < targetHeight)) {
|
|
281
303
|
paddingCount--;
|
|
282
304
|
}
|
|
283
|
-
if (!(offset >= 0)) {
|
|
284
|
-
break;
|
|
285
|
-
}
|
|
286
305
|
var item = childrenMap[offset];
|
|
287
306
|
if (!item) {
|
|
288
307
|
item = createItem(offset);
|
|
@@ -313,7 +332,6 @@ function ylist(container, generator, $Y) {
|
|
|
313
332
|
} else {
|
|
314
333
|
deltaScroll = patchTop(deltaY, animate);
|
|
315
334
|
}
|
|
316
|
-
|
|
317
335
|
if (deltaScroll) {
|
|
318
336
|
if (animate && __scrollBy) {
|
|
319
337
|
list.scrollTop += deltaScroll - deltaY;
|
|
@@ -378,13 +396,20 @@ function ylist(container, generator, $Y) {
|
|
|
378
396
|
};
|
|
379
397
|
if (!/^i(Phone|Pod|Watch|Pad)|^Mac/i.test(navigator.platform)) var __scrollBy = list.scrollBy;
|
|
380
398
|
list.scrollBy = scrollBy;
|
|
381
|
-
list.index = function () {
|
|
399
|
+
list.index = function (update) {
|
|
400
|
+
if (update === false) return saved_itemIndex;
|
|
382
401
|
var firstElement = getFirstVisibleElement();
|
|
383
402
|
if (!firstElement) return saved_itemIndex;
|
|
384
403
|
var index = firstElement.index;
|
|
385
|
-
var scrolled = (list.scrollTop - firstElement.offsetTop + parseFloat(getComputedStyle(list).paddingTop)) / firstElement.offsetHeight;
|
|
404
|
+
var scrolled = (list.scrollTop - firstElement.offsetTop + parseFloat(getComputedStyle(list).paddingTop) + .5 | 0) / firstElement.offsetHeight;
|
|
386
405
|
return index + scrolled;
|
|
387
406
|
};
|
|
407
|
+
on("remove")(list, function () {
|
|
408
|
+
saved_itemIndex = list.index();
|
|
409
|
+
});
|
|
410
|
+
on("append")(list, function () {
|
|
411
|
+
if (isFinite(saved_itemIndex)) list.go(saved_itemIndex);
|
|
412
|
+
})
|
|
388
413
|
list.topIndex = function () {
|
|
389
414
|
var element = getFirstElement(1);
|
|
390
415
|
return element ? element.index : 0;
|
|
@@ -392,6 +417,7 @@ function ylist(container, generator, $Y) {
|
|
|
392
417
|
list.getIndexedElement = getIndexedElement;
|
|
393
418
|
list.patchBottom = patchBottom;
|
|
394
419
|
list.patchTop = patchTop;
|
|
420
|
+
list.scrollIfNotCover = scrollIfNotCover;
|
|
395
421
|
vbox(list, $Y);
|
|
396
422
|
return list;
|
|
397
423
|
}
|
|
@@ -400,7 +426,7 @@ var xlist = arriswise(ylist, allArgumentsNames.concat([].slice.call(arguments, 0
|
|
|
400
426
|
|
|
401
427
|
var getGeneratorFromArray = function (source) {
|
|
402
428
|
return function (index) {
|
|
403
|
-
if (index >= source.length) return null;
|
|
429
|
+
if (index >= source.length || index < 0) return null;
|
|
404
430
|
return block(source[index]);
|
|
405
431
|
};
|
|
406
432
|
};
|
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
|
@@ -154,17 +154,28 @@ function main(elem, mode) {
|
|
|
154
154
|
case "y":
|
|
155
155
|
case "vertical":
|
|
156
156
|
var emit = function (item, target) {
|
|
157
|
-
active(elem, item, item
|
|
157
|
+
active(elem, item.value, item, target);
|
|
158
158
|
};
|
|
159
159
|
if ("$src" in elem) {
|
|
160
160
|
getGenerator(elem, 'menu-item');
|
|
161
|
-
|
|
162
|
-
menuList(elem, getTreeFromData(src), emit, direction);
|
|
161
|
+
on("append")(elem, function () {
|
|
163
162
|
elem.registerAsRoot();
|
|
164
163
|
});
|
|
164
|
+
var src0 = [];
|
|
165
|
+
menuList(elem, src0, emit, direction);
|
|
166
|
+
care(elem, function (src) {
|
|
167
|
+
src0.splice(0, src0.length);
|
|
168
|
+
var s = getTreeFromData(src);
|
|
169
|
+
var i = 0;
|
|
170
|
+
while (i < s.length) {
|
|
171
|
+
src0.push.apply(src0, s.slice(i, i += 1000));
|
|
172
|
+
}
|
|
173
|
+
elem.go(0);
|
|
174
|
+
});
|
|
165
175
|
}
|
|
166
176
|
else {
|
|
167
177
|
var nodes = getArrayNodes(elem);
|
|
178
|
+
remove(elem.children);
|
|
168
179
|
elem = menuList(elem, nodes, emit, direction);
|
|
169
180
|
elem.registerAsRoot();
|
|
170
181
|
}
|
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,
|
|
@@ -275,7 +275,6 @@ function main(page, items, active, direction = 'y') {
|
|
|
275
275
|
var className = `{'has-children':${itemName}.children&&${itemName}.children.length,'warn':${itemName}.type==='danger'||${itemName}.type==='warn'||${itemName}.type==='red'}`;
|
|
276
276
|
var notHidden = `!${itemName}.hidden`;
|
|
277
277
|
var generator = getGenerator(page, 'menu-item');
|
|
278
|
-
|
|
279
278
|
list(page, function (index) {
|
|
280
279
|
var item = items[index];
|
|
281
280
|
if (!item) return;
|
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/picture.js
CHANGED
|
@@ -17,8 +17,15 @@ var getstation = function (n, s) {
|
|
|
17
17
|
return n;
|
|
18
18
|
};
|
|
19
19
|
var _createImage = function (url, callback) {
|
|
20
|
-
var imgpic
|
|
21
|
-
|
|
20
|
+
var imgpic;
|
|
21
|
+
if (url instanceof Image) {
|
|
22
|
+
imgpic = new Image;
|
|
23
|
+
imgpic.src = url.src;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
imgpic = document.createElement('img');
|
|
27
|
+
imgpic.src = url;
|
|
28
|
+
}
|
|
22
29
|
var onload = function () {
|
|
23
30
|
imgpic.onload = null;
|
|
24
31
|
callback(imgpic);
|
|
@@ -393,7 +400,6 @@ function picture(url, to = 0, key) {
|
|
|
393
400
|
var gen = function (index, ratio) {
|
|
394
401
|
if (index >= urls.length || index < 0) return null;
|
|
395
402
|
if (images[index] && images[index].url !== urls[index]) {
|
|
396
|
-
console.log(images[index].url, urls[index]);
|
|
397
403
|
delete images[index];
|
|
398
404
|
}
|
|
399
405
|
if (!images[index]) {
|
package/coms/zimoli/popup.js
CHANGED
|
@@ -152,10 +152,6 @@ var createMask = function (element) {
|
|
|
152
152
|
return mask;
|
|
153
153
|
};
|
|
154
154
|
var popup_with_mask = function (element, mask = createMask(element)) {
|
|
155
|
-
if (!mask.clean) {
|
|
156
|
-
mask.clean = new Cleanup(element.with);
|
|
157
|
-
}
|
|
158
|
-
onremove(element, mask.clean);
|
|
159
155
|
css(element, `z-index:${zIndex()};`);
|
|
160
156
|
if (mask.parentNode) {
|
|
161
157
|
global(element, false);
|
|
@@ -167,6 +163,10 @@ var popup_with_mask = function (element, mask = createMask(element)) {
|
|
|
167
163
|
} else {
|
|
168
164
|
if (element.with !== element) element.with = [element.with, mask];
|
|
169
165
|
}
|
|
166
|
+
if (!mask.clean) {
|
|
167
|
+
mask.clean = new Cleanup(element.with);
|
|
168
|
+
}
|
|
169
|
+
onremove(element, mask.clean);
|
|
170
170
|
if (!element.parentNode) global(element, false);
|
|
171
171
|
return element;
|
|
172
172
|
};
|
package/coms/zimoli/render.js
CHANGED
|
@@ -381,7 +381,7 @@ var src2 = function (search) {
|
|
|
381
381
|
temp = "";
|
|
382
382
|
}
|
|
383
383
|
var changes = getChanges(temp, savedValue);
|
|
384
|
-
if (!changes || isEmpty(origin) && isEmpty(this.src)) return;
|
|
384
|
+
if (!changes || isEmpty(origin) && isEmpty(this.src) && isEmpty(savedValue)) return;
|
|
385
385
|
savedValue = temp;
|
|
386
386
|
this.src = origin;
|
|
387
387
|
cast(this, origin);
|
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 = [];
|