efront 3.12.0 → 3.12.4
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/{_cross.js → cross_.js} +9 -9
- package/coms/basic/sortname.js +6 -2
- package/coms/kugou/parseSongsList.js +0 -1
- package/coms/reptile/cross.js +1 -1
- 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/cross.js +3 -3
- package/coms/zimoli/data.js +7 -5
- 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/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 +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/coms/zimoli/vbox.js +1 -1
- package/package.json +1 -1
- package/public/efront.js +1 -1
- package/readme.md +7 -0
|
@@ -46,7 +46,7 @@ function toResponse() {
|
|
|
46
46
|
if (this.responseType === 'json') return JSON.stringify(this.response);
|
|
47
47
|
return this.response;
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function cross_(jsonp, digest = noop, method, url, headers) {
|
|
50
50
|
var originDomain = getDomainPath(url);
|
|
51
51
|
if (!originDomain) throw new Error("路径格式错误!");
|
|
52
52
|
var _cookies = getCookies(originDomain);
|
|
@@ -149,7 +149,7 @@ function _cross(jsonp, digest = noop, method, url, headers) {
|
|
|
149
149
|
}
|
|
150
150
|
location = getRequestProtocol(url) + "//" + location;
|
|
151
151
|
}
|
|
152
|
-
var crs =
|
|
152
|
+
var crs = cross_("get", location, _headers);
|
|
153
153
|
crs.isRedirected = (xhr.isRedirected || 0) + 1;
|
|
154
154
|
crs.done(onload, false);
|
|
155
155
|
crs.error(onerror, false);
|
|
@@ -304,10 +304,10 @@ function reform(r, info, fire, cancel, e) {
|
|
|
304
304
|
function addReform(r) {
|
|
305
305
|
if (isFunction(r)) reforms.push(r);
|
|
306
306
|
}
|
|
307
|
-
var bind =
|
|
308
|
-
|
|
309
|
-
var
|
|
310
|
-
extend(
|
|
307
|
+
var bind = cross_.bind;
|
|
308
|
+
cross_.bind = function () {
|
|
309
|
+
var cross_ = bind.apply(this, arguments);
|
|
310
|
+
extend(cross_, {
|
|
311
311
|
requests,
|
|
312
312
|
abortAll() {
|
|
313
313
|
var rs = requests.splice(0, requests.length);
|
|
@@ -320,10 +320,10 @@ _cross.bind = function () {
|
|
|
320
320
|
addDirect,
|
|
321
321
|
getCrossUrl
|
|
322
322
|
});
|
|
323
|
-
return
|
|
323
|
+
return cross_;
|
|
324
324
|
}
|
|
325
|
-
|
|
326
|
-
|
|
325
|
+
cross_.setHost = setHost;
|
|
326
|
+
cross_.setLocation = function (host) {
|
|
327
327
|
location_href = host;
|
|
328
328
|
if (!base) base = /^https?\:/i.test(location_href) ? '/' : "http://efront.cc/";
|
|
329
329
|
};
|
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/reptile/cross.js
CHANGED
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/cross.js
CHANGED
|
@@ -5,7 +5,7 @@ var saveCookie = lazy(function () {
|
|
|
5
5
|
var { efrontURI, cross_host = efrontURI } = this;
|
|
6
6
|
var location_href = parseURL(location.href);
|
|
7
7
|
location_href = `${location_href.protocol}//${location_href.host}/`;
|
|
8
|
-
|
|
8
|
+
cross_.setLocation(location_href);
|
|
9
9
|
|
|
10
10
|
var cookieItemsInSessionStorageKey = "--zimoli-coms-cross";
|
|
11
11
|
var cookiesData = sessionStorage.getItem(cookieItemsInSessionStorageKey);
|
|
@@ -21,7 +21,7 @@ var digest = function () {
|
|
|
21
21
|
dispatch('render', window);
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
var cross =
|
|
24
|
+
var cross = cross_.bind(function (callback, onerror) {
|
|
25
25
|
var xhr = new XMLHttpRequest;
|
|
26
26
|
var abort = xhr.abort;
|
|
27
27
|
xhr.abort = function () {
|
|
@@ -55,6 +55,6 @@ cross.setHost = function (host) {
|
|
|
55
55
|
if (!host) return console.error("cross_host格式不正确", host);
|
|
56
56
|
var host = parsed.host + (parsed.pathname || '/');
|
|
57
57
|
host = (/^https/.test(location_href) ? "https://" : "http://") + host;
|
|
58
|
-
|
|
58
|
+
cross_.setHost(host);
|
|
59
59
|
};
|
|
60
60
|
if (cross_host) cross.setHost(cross_host);
|
package/coms/zimoli/data.js
CHANGED
|
@@ -165,6 +165,7 @@ function getUrlParamsForApi(api, url) {
|
|
|
165
165
|
var params = {};
|
|
166
166
|
url = url.replace(/[\?#]*$/g, function (match) {
|
|
167
167
|
match.split(/[&#\?]+/).forEach(function (s) {
|
|
168
|
+
if (!s) return;
|
|
168
169
|
var [k, v] = s.split("=");
|
|
169
170
|
params[k] = v;
|
|
170
171
|
});
|
|
@@ -176,7 +177,7 @@ function getUrlParamsForApi(api, url) {
|
|
|
176
177
|
});
|
|
177
178
|
});
|
|
178
179
|
params = serialize(params);
|
|
179
|
-
return
|
|
180
|
+
return params;
|
|
180
181
|
}
|
|
181
182
|
|
|
182
183
|
function __seekprop(data, prop) {
|
|
@@ -204,7 +205,7 @@ function seekResponse(data, seeker, apiMap = {}) {
|
|
|
204
205
|
}
|
|
205
206
|
if (data && prop) {
|
|
206
207
|
var reg1 = /[\:\>\\]/, next;
|
|
207
|
-
var getNextValue =
|
|
208
|
+
var getNextValue = !/\:/.test(prop);
|
|
208
209
|
if (reg1.test(prop)) {
|
|
209
210
|
var [prop, next, pick] = prop.split(reg1);
|
|
210
211
|
next = apiMap[next];
|
|
@@ -231,8 +232,8 @@ function seekResponse(data, seeker, apiMap = {}) {
|
|
|
231
232
|
data = JSON.parse(data);
|
|
232
233
|
}
|
|
233
234
|
if (next) {
|
|
234
|
-
data = getUrlParamsForApi(next, data);
|
|
235
|
-
if (
|
|
235
|
+
data = (pick || next.id) + "?" + getUrlParamsForApi(next, data);
|
|
236
|
+
if (getNextValue) {
|
|
236
237
|
data = getParamsFromUrl(data);
|
|
237
238
|
if (pick) data = data[pick];
|
|
238
239
|
}
|
|
@@ -927,6 +928,7 @@ var data = {
|
|
|
927
928
|
setSource(sourceid, value) {
|
|
928
929
|
var rememberWithStorage;
|
|
929
930
|
if (isObject(sourceid)) {
|
|
931
|
+
|
|
930
932
|
this.rebuildInstance(dataSourceMap, sourceid);
|
|
931
933
|
rememberWithStorage = value;
|
|
932
934
|
} else {
|
|
@@ -975,7 +977,7 @@ var data = {
|
|
|
975
977
|
if (key === true || key === false || isEmpty(key)) {
|
|
976
978
|
rememberWithStorage = key;
|
|
977
979
|
key = null;
|
|
978
|
-
var value = instance;
|
|
980
|
+
var value = instance.valueOf();
|
|
979
981
|
} else {
|
|
980
982
|
var value = instance[key];
|
|
981
983
|
}
|
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,11 +396,12 @@ 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
|
};
|
|
388
407
|
list.topIndex = function () {
|
|
@@ -392,7 +411,14 @@ function ylist(container, generator, $Y) {
|
|
|
392
411
|
list.getIndexedElement = getIndexedElement;
|
|
393
412
|
list.patchBottom = patchBottom;
|
|
394
413
|
list.patchTop = patchTop;
|
|
414
|
+
list.scrollIfNotCover = scrollIfNotCover;
|
|
395
415
|
vbox(list, $Y);
|
|
416
|
+
on("remove")(list, function () {
|
|
417
|
+
saved_itemIndex = list.index();
|
|
418
|
+
});
|
|
419
|
+
on("append")(list, function () {
|
|
420
|
+
if (isFinite(saved_itemIndex)) list.go(saved_itemIndex);
|
|
421
|
+
})
|
|
396
422
|
return list;
|
|
397
423
|
}
|
|
398
424
|
var allArgumentsNames = arguments[arguments.length - 1];
|
|
@@ -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/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 = [];
|