efront 3.26.5 → 3.26.7
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/Speed.js +8 -6
- package/coms/basic/cross_.js +12 -9
- package/coms/basic/isArrayLike.js +10 -0
- package/coms/basic/loader.js +26 -22
- package/coms/basic/parseURL.js +23 -4
- package/coms/basic/parseURL_test.js +7 -0
- package/coms/zimoli/appendChild.js +1 -1
- package/coms/zimoli/container.js +4 -1
- package/coms/zimoli/data.js +59 -19
- package/coms/zimoli/getGenerator.js +19 -9
- package/coms/zimoli/list.js +13 -9
- package/coms/zimoli/menu.js +1 -2
- package/coms/zimoli/model.js +0 -1
- package/coms/zimoli/move.js +1 -1
- package/coms/zimoli/popup.js +2 -2
- package/coms/zimoli/render.js +152 -88
- package/coms/zimoli/select.js +30 -8
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/coms/basic/Speed.js
CHANGED
|
@@ -102,6 +102,7 @@ class Speed extends Array {
|
|
|
102
102
|
cache = [];
|
|
103
103
|
stamp = 0;
|
|
104
104
|
deltat = 0;
|
|
105
|
+
accelerate = .1;
|
|
105
106
|
static now() {
|
|
106
107
|
return performance.now ? performance.now() : Date.now();
|
|
107
108
|
}
|
|
@@ -143,22 +144,23 @@ class Speed extends Array {
|
|
|
143
144
|
var ratio;
|
|
144
145
|
if (this.stamp) ratio = now - this.stamp;
|
|
145
146
|
else ratio = deltat;
|
|
146
|
-
if (ratio > 160) ratio = 1e-
|
|
147
|
+
if (ratio > 160) ratio = 1e-7;
|
|
147
148
|
if (this.deltat) {
|
|
148
149
|
if (deltat > this.deltat * 10) {
|
|
149
|
-
ratio = 1e-
|
|
150
|
+
ratio = 1e-7;
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
153
|
this.deltat = deltat;
|
|
153
154
|
this.stamp = now;
|
|
154
155
|
var sum = 0;
|
|
155
156
|
for (var v of values) sum += v * v;
|
|
156
|
-
v = Math.sqrt(sum)
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
v = Math.sqrt(sum);
|
|
158
|
+
var a = this.accelerate * Math.atan(v + 1);
|
|
159
|
+
if (v > a + 1e-14) {
|
|
160
|
+
v = Math.sqrt(v * (v - a)) / v;
|
|
159
161
|
}
|
|
160
162
|
else {
|
|
161
|
-
v =
|
|
163
|
+
v = 1e-9;
|
|
162
164
|
}
|
|
163
165
|
var r = ratio * v;
|
|
164
166
|
for (var cx = 0, dx = values.length; cx < dx; cx++) {
|
package/coms/basic/cross_.js
CHANGED
|
@@ -127,7 +127,9 @@ var mergedata = function (cachedata, pkv) {
|
|
|
127
127
|
}
|
|
128
128
|
return res;
|
|
129
129
|
};
|
|
130
|
-
|
|
130
|
+
function createResponse(response, status = 0) {
|
|
131
|
+
return { status, response: response, toString: toResponse }
|
|
132
|
+
}
|
|
131
133
|
/**
|
|
132
134
|
* @param { () => XMLHttpRequest } jsonp
|
|
133
135
|
* @this { () => XMLHttpRequest }
|
|
@@ -162,12 +164,15 @@ function cross_(jsonp, digest = noop, method, url, headers) {
|
|
|
162
164
|
if (!~requests.indexOf(_xhr)) return;
|
|
163
165
|
removeFromList(requests, _xhr);
|
|
164
166
|
errored = e || "未知错误!";
|
|
167
|
+
if (typeof errored === 'string') {
|
|
168
|
+
errored = createResponse(e, xhr.status);
|
|
169
|
+
}
|
|
165
170
|
flush();
|
|
166
171
|
digest();
|
|
167
172
|
};
|
|
168
173
|
var onerror = async function (e) {
|
|
169
174
|
if (e.type === 'error') {
|
|
170
|
-
e =
|
|
175
|
+
e = createResponse("无法访问服务器!");
|
|
171
176
|
}
|
|
172
177
|
for (var r of reforms) {
|
|
173
178
|
var r = await reform.call(xhr, r, { method, url, status: xhr.status, headers: _headers }, fire, onerror1, e);
|
|
@@ -245,13 +250,13 @@ function cross_(jsonp, digest = noop, method, url, headers) {
|
|
|
245
250
|
xhr.responseText = xhr.response;
|
|
246
251
|
}
|
|
247
252
|
catch (e) {
|
|
248
|
-
return onerror(
|
|
253
|
+
return onerror("数据无法解析!")
|
|
249
254
|
}
|
|
250
255
|
};
|
|
251
256
|
switch (xhr.status) {
|
|
252
257
|
case 0:
|
|
253
258
|
if (!xhr.response) {
|
|
254
|
-
onerror(
|
|
259
|
+
onerror("无法访问服务器");
|
|
255
260
|
break;
|
|
256
261
|
}
|
|
257
262
|
case 200:
|
|
@@ -312,9 +317,7 @@ function cross_(jsonp, digest = noop, method, url, headers) {
|
|
|
312
317
|
forceForm = true;
|
|
313
318
|
xhr.data(data);
|
|
314
319
|
};
|
|
315
|
-
var fire = async function () {
|
|
316
|
-
if (!~requests.indexOf(xhr)) return;
|
|
317
|
-
var code = await xhr.encrypt;
|
|
320
|
+
var fire = async function (code) {
|
|
318
321
|
if (!~requests.indexOf(xhr)) return;
|
|
319
322
|
xhr.encrypt = code;
|
|
320
323
|
var isform = /^f/i.test(method);
|
|
@@ -366,7 +369,7 @@ function cross_(jsonp, digest = noop, method, url, headers) {
|
|
|
366
369
|
else send.call(xhr);
|
|
367
370
|
digest();
|
|
368
371
|
};
|
|
369
|
-
Promise.resolve().then(fire);
|
|
372
|
+
Promise.resolve(xhr.encrypt).then(fire, onerror1);
|
|
370
373
|
}
|
|
371
374
|
var setRequestHeader = xhr.setRequestHeader;
|
|
372
375
|
var realHeaders = Object.create(null);
|
|
@@ -448,7 +451,7 @@ function addReform(r) {
|
|
|
448
451
|
function getCode() {
|
|
449
452
|
return new Promise((ok, oh) => {
|
|
450
453
|
this('get', base + "!").then((xhr) => { return ok(encode62.timedecode(xhr.response || xhr.responseText)) }, () => {
|
|
451
|
-
return oh('
|
|
454
|
+
return oh('无法连接可加密的服务器!');
|
|
452
455
|
});
|
|
453
456
|
});
|
|
454
457
|
}
|
package/coms/basic/loader.js
CHANGED
|
@@ -323,16 +323,18 @@ var loadModule = function (name, then, prebuilds = {}) {
|
|
|
323
323
|
}
|
|
324
324
|
};
|
|
325
325
|
var toRem = text => pixelDecoder && typeof text === 'string' ? text.replace(/(\:\s*)?\b((?:\d*\.)?\d+)px(\s*\))?/ig, (m, h, d, quote) => (h || "") + (d !== '1' ? h && quote ? renderPixelRatio * d + "pt" : pixelDecoder(d) : renderPixelRatio > 1 ? ".78pt" : 0.78 / devicePixelRatio + "pt") + (quote || "")) : text;
|
|
326
|
-
if (document
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
326
|
+
if (document) {
|
|
327
|
+
if (document.head) {
|
|
328
|
+
var efrontsign = document.head.lastElementChild.attributes[0];
|
|
329
|
+
if (efrontsign && /^compiledinfo\-/.test(efrontsign.name)) efrontsign = efrontsign.name.slice(efrontsign.name.indexOf('-') + 1);
|
|
330
|
+
else efrontsign = '';
|
|
331
|
+
}
|
|
332
|
+
else if (document.getElementsByTagName) {
|
|
333
|
+
document.head = document.getElementsByTagName("head")[0];
|
|
334
|
+
efrontsign = /\<script\s+compiledinfo\-(\S*?)\s*\=/i.exec(document.head.lastChild.outerHTML);
|
|
335
|
+
if (efrontsign) efrontsign = efrontsign[1];
|
|
336
|
+
else efrontsign = '';
|
|
337
|
+
}
|
|
336
338
|
}
|
|
337
339
|
var uncode = function (text) {
|
|
338
340
|
var ratio = 1;
|
|
@@ -597,10 +599,11 @@ var init = function (name, then, prebuilds) {
|
|
|
597
599
|
var crack = function (error) {
|
|
598
600
|
if (res.resolved || res.errored) return;
|
|
599
601
|
var ed = errored[name];
|
|
600
|
-
console.error(`加载${name}失败,${ed && ed.length ? `${ed.join(', ')} 等${ed.length}个模块` : "没有其他模块"}受到影响`);
|
|
601
602
|
res.errored = true;
|
|
602
603
|
res.error = error;
|
|
603
604
|
res.fire();
|
|
605
|
+
console.error(`加载${name}失败,${ed && ed.length ? `${ed.join(', ')} 等${ed.length}个模块` : "没有其他模块"}受到影响`);
|
|
606
|
+
if (window.document) throw error;
|
|
604
607
|
};
|
|
605
608
|
loadModule(name, function (error) {
|
|
606
609
|
if (hasOwnProperty.call(modules, name)) {
|
|
@@ -860,18 +863,19 @@ var requires_count = 3;
|
|
|
860
863
|
var hook = function (requires_count) {
|
|
861
864
|
if (requires_count !== 0) return;
|
|
862
865
|
"alert confirm innerWidth innerHeight close prompt".split(/\s+/).map(removeGlobalProperty);
|
|
863
|
-
initPixelDecoder();
|
|
864
866
|
modules.Promise = Promise;
|
|
865
867
|
modules.hook_time = +new Date;
|
|
866
|
-
if (
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
868
|
+
if (document) {
|
|
869
|
+
initPixelDecoder();
|
|
870
|
+
if (modules.hook_time - efront_time < (isProduction ? 30 : 5) && document.querySelector && devicePixelRatio > 1 && /Linux/.test(navigator.platform) && navigator.maxTouchPoints > 0) {
|
|
871
|
+
let ratio = +(1000000 / devicePixelRatio + .5 | 0) / 1000000;
|
|
872
|
+
document.querySelector("meta[name=viewport]").setAttribute("content", `width=device-width,target-densitydpi=device-dpi,user-scalable=no,initial-scale=1,maximum-scale=${ratio}`);
|
|
873
|
+
renderPixelRatio *= devicePixelRatio;
|
|
874
|
+
modules.renderPixelRatio = renderPixelRatio;
|
|
875
|
+
devicePixelRatio = modules.devicePixelRatio = 1;
|
|
876
|
+
}
|
|
877
|
+
if (!efrontPath) efrontPath = document.body.getAttribute("main-path") || document.body.getAttribute("path") || document.body.getAttribute("main") || "zimoli";
|
|
873
878
|
}
|
|
874
|
-
|
|
875
879
|
init(efrontPath, function (zimoli) {
|
|
876
880
|
if (zimoli instanceof Function) zimoli();
|
|
877
881
|
});
|
|
@@ -881,7 +885,7 @@ var initIfNotDefined = function (defined, path, onload) {
|
|
|
881
885
|
else hook(--requires_count);
|
|
882
886
|
};
|
|
883
887
|
|
|
884
|
-
loadResponseTreeFromStorage();
|
|
888
|
+
if(document) loadResponseTreeFromStorage();
|
|
885
889
|
initIfNotDefined([].map, "[]map", map => map);
|
|
886
890
|
initIfNotDefined(Promise, "Promise", promise => Promise = promise);
|
|
887
891
|
if (!isProduction) window.modules = modules;
|
|
@@ -889,5 +893,5 @@ var onload = function () {
|
|
|
889
893
|
window.onload = null;
|
|
890
894
|
hook(--requires_count);
|
|
891
895
|
};
|
|
892
|
-
if (document.body) onload();
|
|
896
|
+
if (!document || document.body) onload();
|
|
893
897
|
else window.onload = onload;
|
package/coms/basic/parseURL.js
CHANGED
|
@@ -17,11 +17,30 @@
|
|
|
17
17
|
// │ href │
|
|
18
18
|
// └────────────────────────────────────────────────────────────────────────────────────────────────┘
|
|
19
19
|
|
|
20
|
-
// -------/// ---------------1---------------------------------///////////////////2-----3--------//////// ------4----2/////5---------------------------------------------------6
|
|
21
|
-
var reg = /^([^\:\/\\\?#\[]+\:(?![^\:\/\\\?\#]*@|[\/\\][^\/\\]))?(?:\/\/|\\\\)?(?:(([^\:\/\\\?#]+)?(?:\:([^\/\\\?#]+))?)@)?(([^\/\\@\?\#\.]*?[^\/\\@\:\?\#\.\d][^\/\\@\:\?\#\.]*?|[^\/\\@\:\?\#\.]+(?:\:[\@\/\\\?#\.]*[^\d\@\:\/\\\?#\.]
|
|
22
|
-
|
|
20
|
+
// -------/// ---------------1---------------------------------///////////////////2-----3--------//////// ------4----2/////5---------------------------------------------------6-----------------------------------------------------------------------------------//////////////-7--5///8-------9----------//10--11---10/8/--12----////
|
|
21
|
+
var reg = /^([^\:\/\\\?#\[]+\:(?![^\:\/\\\?\#]*@|[\/\\][^\/\\]))?(?:\/\/|\\\\)?(?:(([^\:\/\\\?#]+)?(?:\:([^\/\\\?#]+))?)@)?(([^\/\\@\?\#\.]*?[^\/\\@\:\?\#\.\d][^\/\\@\:\?\#\.]*?|[^\/\\@\:\?\#\.]+(?:\:[\@\/\\\?#\.]*[^\d\@\:\/\\\?#\.]+|(?:\.[^\/\\@\:\?\#\.]+)+))?(?:(?:\:|^)(\d+))?)(((?:\/|\\|^)[^\?#]*)?(\?([^#]*))?)(#[\s\S]*)?$/;
|
|
22
|
+
var hrefDescriptor = {
|
|
23
|
+
get() {
|
|
24
|
+
var href = '';
|
|
25
|
+
if (this.protocol) href += this.protocol;
|
|
26
|
+
if (this.auth) href += "//" + this.auth + "@" + this.host;
|
|
27
|
+
else if (this.host) href += "//" + this.host;
|
|
28
|
+
if (this.path) href += this.path;
|
|
29
|
+
if (this.hash) href += this.hash;
|
|
30
|
+
return href;
|
|
31
|
+
},
|
|
32
|
+
set(href) {
|
|
33
|
+
Object.assign(this, parseURL(href));
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
function parse(url) {
|
|
23
37
|
if (url === undefined || url === null) url = '';
|
|
24
38
|
var [__, protocol, auth, username, password, host, hostname, port, path, pathname, search, query, hash] = reg.exec(url);
|
|
25
|
-
return { protocol, auth, username, password, host, hostname, port, path, pathname, search, query, hash
|
|
39
|
+
return { protocol, auth, username, password, host, hostname, port, path, pathname, search, query, hash };
|
|
40
|
+
}
|
|
41
|
+
function parseURL(url) {
|
|
42
|
+
var obj = parse(url);
|
|
43
|
+
Object.defineProperty(obj, "href", hrefDescriptor);
|
|
44
|
+
return obj;
|
|
26
45
|
}
|
|
27
46
|
module.exports = parseURL;
|
|
@@ -12,6 +12,10 @@ test('http://yunxu1019@live.cn@github.com/?a', 'username', 'yunxu1019@live.cn')
|
|
|
12
12
|
test('localhost', 'host', 'localhost')
|
|
13
13
|
test('localhost:80', 'port', '80')
|
|
14
14
|
test('localhost:80/', 'port', '80')
|
|
15
|
+
test('magnet:?xt=::', 'search', '?xt=::')
|
|
16
|
+
test('magnet:?xt=::', 'protocol', 'magnet:')
|
|
17
|
+
test('magnet:?xt=::', 'host', '')
|
|
18
|
+
test('magnet:?xt=::', 'pathname', undefined)
|
|
15
19
|
test('efront.cc', 'host', 'efront.cc')
|
|
16
20
|
test('127.0.0.1', 'host', '127.0.0.1')
|
|
17
21
|
test(':80', 'port', '80')
|
|
@@ -25,6 +29,9 @@ test('c:a:b@a80', 'auth', 'a:b')
|
|
|
25
29
|
test('c:d:a:b@a80', 'password', 'a:b')
|
|
26
30
|
test('localhost:', 'protocol', 'localhost:')
|
|
27
31
|
test('localhost:80', 'hostname', 'localhost')
|
|
32
|
+
test('efront.cc', 'hostname', 'efront.cc')
|
|
33
|
+
test('efront.', 'hostname', undefined)
|
|
34
|
+
test('efront.', 'pathname', "efront.")
|
|
28
35
|
test('http//:80', 'hostname', 'http')
|
|
29
36
|
test('http//:80', 'pathname', '//:80')
|
|
30
37
|
test('//h:80', 'host', 'h:80')
|
|
@@ -25,7 +25,7 @@ function appendChild(parent, obj, transition) {
|
|
|
25
25
|
if (transition === false) {
|
|
26
26
|
var children = [].concat(obj);
|
|
27
27
|
} else {
|
|
28
|
-
var children =
|
|
28
|
+
var children = isArrayLike(obj) ? slice.call(obj, 0) : slice.call(arguments, 1);
|
|
29
29
|
}
|
|
30
30
|
if (parent.appendChild) {
|
|
31
31
|
for (var cx = 0, dx = children.length; cx < dx; cx++) {
|
package/coms/zimoli/container.js
CHANGED
package/coms/zimoli/data.js
CHANGED
|
@@ -660,11 +660,45 @@ function responseCrash(e, data) {
|
|
|
660
660
|
}
|
|
661
661
|
error_report(e, e.status < 500 ? 'warn' : 'error');
|
|
662
662
|
}
|
|
663
|
-
var
|
|
663
|
+
var toDataString = function () { return isEmpty(this.data) ? '' : this.data };
|
|
664
664
|
var updateLoadingCount = function () {
|
|
665
665
|
data.loading_count = cross.requests.length;
|
|
666
666
|
};
|
|
667
667
|
on('render')(window, updateLoadingCount, true);
|
|
668
|
+
var bubApply = function (f, args) {
|
|
669
|
+
if (args.length === 1) {
|
|
670
|
+
var [instanceMap] = args;
|
|
671
|
+
for (var k in instanceMap) {
|
|
672
|
+
f(k, instanceMap[k]);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
else if (args.length === 2) {
|
|
676
|
+
var [instanceId, callback] = args;
|
|
677
|
+
f(instanceId, callback);
|
|
678
|
+
}
|
|
679
|
+
};
|
|
680
|
+
|
|
681
|
+
var bindInstance = function (instanceId, callback) {
|
|
682
|
+
if (!instanceListenerMap[instanceId]) {
|
|
683
|
+
instanceListenerMap[instanceId] = [];
|
|
684
|
+
}
|
|
685
|
+
var listeners = instanceListenerMap[instanceId];
|
|
686
|
+
if (!~listeners.indexOf(callback)) {
|
|
687
|
+
listeners.push(callback);
|
|
688
|
+
}
|
|
689
|
+
if (hasItem(instanceId)) callback(getItem(instanceId));
|
|
690
|
+
};
|
|
691
|
+
var unbindInstance = function (instanceId, callback) {
|
|
692
|
+
if (!instanceListenerMap[instanceId]) return;
|
|
693
|
+
if (!callback) {
|
|
694
|
+
delete instanceListenerMap[instanceId];
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
removeFromList(instanceListenerMap[instanceId], callback);
|
|
698
|
+
if (!instanceListenerMap[instanceId].length) {
|
|
699
|
+
delete instanceListenerMap[instanceId];
|
|
700
|
+
}
|
|
701
|
+
};
|
|
668
702
|
var data = {
|
|
669
703
|
decodeStructure,
|
|
670
704
|
encodeStructure,
|
|
@@ -1052,31 +1086,37 @@ var data = {
|
|
|
1052
1086
|
}
|
|
1053
1087
|
return this.setInstance(instanceId, instance, rememberWithStorage);
|
|
1054
1088
|
},
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1089
|
+
/**
|
|
1090
|
+
* bindInstance(instanceId, callback);
|
|
1091
|
+
* bindInstance(instanceMap);
|
|
1092
|
+
* bindInstance(page, instanceId, callback);
|
|
1093
|
+
* bindInstance(page, instanceMap);
|
|
1094
|
+
*/
|
|
1095
|
+
bindInstance() {
|
|
1096
|
+
var [page] = arguments;
|
|
1097
|
+
if (isNode(page)) {
|
|
1098
|
+
var restargs = Array.prototype.slice.call(arguments, 1);
|
|
1099
|
+
onmounted(page, function () {
|
|
1100
|
+
bubApply(bindInstance, restargs);
|
|
1101
|
+
});
|
|
1102
|
+
on("remove")(page, function () {
|
|
1103
|
+
bubApply(unbindInstance, restargs);
|
|
1104
|
+
});
|
|
1058
1105
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
listeners.push(callback);
|
|
1106
|
+
else {
|
|
1107
|
+
bubApply(bindInstance, arguments);
|
|
1062
1108
|
}
|
|
1063
|
-
if (hasItem(instanceId)) callback(getItem(instanceId));
|
|
1064
1109
|
},
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
}
|
|
1071
|
-
removeFromList(instanceListenerMap[instanceId], callback);
|
|
1072
|
-
if (!instanceListenerMap[instanceId].length) {
|
|
1073
|
-
delete instanceListenerMap[instanceId];
|
|
1074
|
-
}
|
|
1110
|
+
/**
|
|
1111
|
+
* 仅用于解除没有与DOM节点绑定的事件
|
|
1112
|
+
*/
|
|
1113
|
+
unbindInstance() {
|
|
1114
|
+
bubApply(unbindInstance, arguments);
|
|
1075
1115
|
},
|
|
1076
1116
|
rebuildInstance(instance, data, old = instance) {
|
|
1077
1117
|
if (instance === data) return;
|
|
1078
1118
|
if (!isObject(instance)) throw new Error("只支持object类型的数据!");
|
|
1079
|
-
if (!isObject(data)) data = { data }, data.toString = data.valueOf =
|
|
1119
|
+
if (!isObject(data)) data = { data }, data.toString = data.valueOf = toDataString;
|
|
1080
1120
|
if (instance instanceof Array) instance.splice(0, instance.length);
|
|
1081
1121
|
var sample = new LoadingArray;
|
|
1082
1122
|
Object.keys(old).forEach(function (k) {
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
|
|
2
2
|
var _slider = createElement(div);
|
|
3
|
+
/**
|
|
4
|
+
* @param {Element} template
|
|
5
|
+
*/
|
|
6
|
+
var cloneChildNodes = function (template) {
|
|
7
|
+
var cloned = template.cloneNode(true);
|
|
8
|
+
var cNodes = cloned.childNodes;
|
|
9
|
+
var tNodes = template.childNodes;
|
|
10
|
+
for (var cx = 0, dx = cNodes.length; cx < dx; cx++) {
|
|
11
|
+
cNodes[cx].$struct = tNodes[cx].$struct;
|
|
12
|
+
cNodes[cx].renderid = tNodes[cx].renderid;
|
|
13
|
+
}
|
|
14
|
+
return cNodes;
|
|
15
|
+
}
|
|
16
|
+
|
|
3
17
|
/**
|
|
4
18
|
* @param {Element} container
|
|
5
19
|
* @param {Element|string} tagName;
|
|
@@ -26,6 +40,7 @@ var getGenerator = function (container, tagName = 'item') {
|
|
|
26
40
|
container.paddingCount = paddingCount;
|
|
27
41
|
}
|
|
28
42
|
appendChild(template, templates);
|
|
43
|
+
render.struct(templates);
|
|
29
44
|
if (templates.length) container.$template = template;
|
|
30
45
|
container.insertBefore = _slider.insertBefore;
|
|
31
46
|
container.appendChild = _slider.appendChild;
|
|
@@ -47,9 +62,9 @@ var getGenerator = function (container, tagName = 'item') {
|
|
|
47
62
|
needSetAttr = false;
|
|
48
63
|
}
|
|
49
64
|
else {
|
|
50
|
-
var
|
|
51
|
-
element =
|
|
52
|
-
if (
|
|
65
|
+
var childNodes = cloneChildNodes(template);
|
|
66
|
+
element = childNodes[0];
|
|
67
|
+
if (childNodes.length > 1) element.with = Array.prototype.slice.call(childNodes, 1);
|
|
53
68
|
}
|
|
54
69
|
if (needSetAttr) {
|
|
55
70
|
for (var a of tagName.attributes) {
|
|
@@ -59,12 +74,7 @@ var getGenerator = function (container, tagName = 'item') {
|
|
|
59
74
|
var scopes = container.$generatorScopes;
|
|
60
75
|
var parsedSrc = container.$src;
|
|
61
76
|
if (parsedSrc) {
|
|
62
|
-
var
|
|
63
|
-
var newScope = {
|
|
64
|
-
[keyName || '$key']: index,
|
|
65
|
-
[itemName || '$item']: com,
|
|
66
|
-
[indexName || '$index']: index
|
|
67
|
-
};
|
|
77
|
+
var newScope = parsedSrc.createScope(com, index, index);
|
|
68
78
|
var newItem = render(element, newScope, scopes, false);
|
|
69
79
|
if (element.with) newItem.with = render(element.with, newScope, scopes, false);
|
|
70
80
|
} else {
|
package/coms/zimoli/list.js
CHANGED
|
@@ -612,24 +612,24 @@ function list() {
|
|
|
612
612
|
}
|
|
613
613
|
}
|
|
614
614
|
}
|
|
615
|
-
var bindSrc =
|
|
615
|
+
var bindSrc = isNode(container) && "$src" in container;
|
|
616
616
|
if (container instanceof Array) {
|
|
617
617
|
generator = getGeneratorFromArray(container);
|
|
618
618
|
bindSrc = container;
|
|
619
619
|
container = div();
|
|
620
620
|
} else if (container && !generator) {
|
|
621
|
-
if (
|
|
621
|
+
if (bindSrc) {
|
|
622
622
|
generator = getGenerator(container);
|
|
623
|
-
care(container, function () {
|
|
624
|
-
var index = container.index();
|
|
625
|
-
container.clean();
|
|
626
|
-
container.go(index || 0);
|
|
627
|
-
});
|
|
628
623
|
bindSrc = true;
|
|
629
624
|
} else {
|
|
630
625
|
generator = function () { }
|
|
631
626
|
}
|
|
632
627
|
}
|
|
628
|
+
if (bindSrc === true) care(container, function () {
|
|
629
|
+
var index = container.index();
|
|
630
|
+
container.clean();
|
|
631
|
+
container.go(index || 0);
|
|
632
|
+
});
|
|
633
633
|
|
|
634
634
|
if (!$Y) {
|
|
635
635
|
if (container) {
|
|
@@ -648,8 +648,12 @@ function list() {
|
|
|
648
648
|
container.go(container.index() || 0);
|
|
649
649
|
}
|
|
650
650
|
list.clean = function () {
|
|
651
|
-
var children = (container || list).
|
|
652
|
-
children =
|
|
651
|
+
var children = (container || list).childNodes;
|
|
652
|
+
children = Array.prototype.filter.call(children, c => {
|
|
653
|
+
if (isFinite(c.index)) return true;
|
|
654
|
+
if (c.nodeType === 1 && c.$comment && isFinite(c.$comment.index)) return true;
|
|
655
|
+
return false;
|
|
656
|
+
});
|
|
653
657
|
remove(children);
|
|
654
658
|
};
|
|
655
659
|
|
package/coms/zimoli/menu.js
CHANGED
|
@@ -196,7 +196,6 @@ function main(elem, mode) {
|
|
|
196
196
|
};
|
|
197
197
|
if ("$src" in elem) {
|
|
198
198
|
var src0 = [];
|
|
199
|
-
menuList(elem, src0, emit, direction);
|
|
200
199
|
care(elem, function (src) {
|
|
201
200
|
bindGlobalkey(elem, src.keymap, emit);
|
|
202
201
|
src0.splice(0, src0.length);
|
|
@@ -212,8 +211,8 @@ function main(elem, mode) {
|
|
|
212
211
|
while (i < s.length) {
|
|
213
212
|
src0.push.apply(src0, s.slice(i, i += 1000));
|
|
214
213
|
}
|
|
215
|
-
elem.go(0);
|
|
216
214
|
});
|
|
215
|
+
menuList(elem, src0, emit, direction);
|
|
217
216
|
}
|
|
218
217
|
else {
|
|
219
218
|
var nodes = getArrayNodes(elem);
|
package/coms/zimoli/model.js
CHANGED
|
@@ -279,7 +279,6 @@ function main(elem) {
|
|
|
279
279
|
}
|
|
280
280
|
} else {
|
|
281
281
|
var create = field_type === "function" ? field_editor : findEditerForElement(field_type, elem) || constructors[field_type];
|
|
282
|
-
console.log(create === constructors.select)
|
|
283
282
|
var ipt = create ? create(elem, field_ref) : field.key ? input(function () {
|
|
284
283
|
var input = document.createElement('input');
|
|
285
284
|
input.setAttribute('type', field.type);
|
package/coms/zimoli/move.js
CHANGED
|
@@ -9,7 +9,7 @@ function getMarginLeft(offsetLeft, offsetWidth, innerWidth) {
|
|
|
9
9
|
// marginLeft*offsetWidth-marginLeft*innerWidth=offsetLeft*offsetWidth
|
|
10
10
|
// marginLeft(offsetWidth-innerWidth)=offsetLeft*offsetWidth
|
|
11
11
|
// marginLeft=offsetLeft*offsetWidth/(offsetWidth-innerWidth)
|
|
12
|
-
if (offsetWidth === +innerWidth) return -offsetWidth / 2;
|
|
12
|
+
if (offsetWidth === +innerWidth || Math.abs(offsetLeft) > Math.abs(offsetWidth - innerWidth)) return -offsetWidth / 2;
|
|
13
13
|
return offsetLeft * offsetWidth / (offsetWidth - innerWidth);
|
|
14
14
|
}
|
|
15
15
|
|
package/coms/zimoli/popup.js
CHANGED
|
@@ -175,12 +175,12 @@ var isypop = function (target) {
|
|
|
175
175
|
if (!target) return false;
|
|
176
176
|
var { offsetParent, nextSibling, previousSibling } = target;
|
|
177
177
|
if (
|
|
178
|
-
nextSibling
|
|
178
|
+
nextSibling
|
|
179
179
|
&& (
|
|
180
180
|
nextSibling.offsetLeft - target.offsetLeft >= target.offsetWidth / 2
|
|
181
181
|
|| target.offsetLeft - nextSibling.offsetLeft >= nextSibling.offsetWidth / 2
|
|
182
182
|
)
|
|
183
|
-
|| previousSibling
|
|
183
|
+
|| previousSibling
|
|
184
184
|
&& (
|
|
185
185
|
previousSibling.offsetLeft - target.offsetLeft >= target.offsetWidth / 2
|
|
186
186
|
|| target.offsetLeft - previousSibling.offsetLeft >= previousSibling.offsetWidth / 2
|