efront 4.22.4 → 4.22.6
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/api.yml +2 -2
- package/apps/pivot/main.js +3 -1
- package/coms/basic/#loader.js +1 -1
- package/coms/basic/cross_.js +20 -4
- package/coms/pivot/checkGeo.js +7 -2
- package/coms/zimoli/XMLHttpRequest.js +1 -0
- package/coms/zimoli/api.js +1 -1
- package/coms/zimoli/render.js +2 -3
- package/coms/zimoli/transition.js +4 -1
- package/coms/zimoli/zimoli.js +160 -105
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/apps/pivot/api.yml
CHANGED
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
unique-save: options ::unique-:data
|
|
35
35
|
recert: options ::recert
|
|
36
36
|
upload: put :path
|
|
37
|
-
https://www.ip.cn
|
|
38
|
-
iplocation: get
|
|
37
|
+
https://www.ip.cn/ referer=https://www.ip.cn/api/index/&Cookie=:empty:
|
|
38
|
+
iplocation: get /api/index/?ip=:ip&type=1
|
|
39
39
|
# https://ipchaxun.com/ :
|
|
40
40
|
# iplocation: get:[].info%20label:nth-child(n+2)>span:nth-child(2) :ip/
|
|
41
41
|
# https://www.ip138.com/:
|
package/apps/pivot/main.js
CHANGED
|
@@ -51,7 +51,9 @@ data.bindInstance("base", async function (base) {
|
|
|
51
51
|
for (var k in apimap) {
|
|
52
52
|
var api = apimap[k];
|
|
53
53
|
if (api.base || !/^\w+\:\/\//.test(api.url)) {
|
|
54
|
-
api.
|
|
54
|
+
if (api.headers && 'authorization' in api.headers) {
|
|
55
|
+
api.base = base.base;
|
|
56
|
+
}
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
});
|
package/coms/basic/#loader.js
CHANGED
|
@@ -49,7 +49,7 @@ var _devicePixelRatio = devicePixelRatio;
|
|
|
49
49
|
var request = window.request || function (url, onload, onerror, version) {
|
|
50
50
|
var xhr = new (XMLHttpRequest || ActiveXObject)("Microsoft.XMLHTTP");
|
|
51
51
|
url = encodeURI(url);
|
|
52
|
-
xhr.open("
|
|
52
|
+
xhr.open("PURGE", url);
|
|
53
53
|
xhr.onreadystatechange = function () {
|
|
54
54
|
if (xhr.readyState === 4) {
|
|
55
55
|
var status = xhr.status;
|
package/coms/basic/cross_.js
CHANGED
|
@@ -398,10 +398,8 @@ function cross_(jsonp, digest = noop, method, url, headers) {
|
|
|
398
398
|
var prepareHeaders = () => {
|
|
399
399
|
cookie_ = this.hostCookie(xhr);
|
|
400
400
|
var _cookies = cookie_.getCookies(originDomain);
|
|
401
|
-
if (_cookies) {
|
|
402
|
-
_headers.Cookie = _cookies;
|
|
403
|
-
}
|
|
404
401
|
var cookobj = null;
|
|
402
|
+
var hasCookie = false;
|
|
405
403
|
for (var k in headers) {
|
|
406
404
|
if (/^\$/.test(headers[k])) {
|
|
407
405
|
var k2 = headers[k].slice(1);
|
|
@@ -416,10 +414,21 @@ function cross_(jsonp, digest = noop, method, url, headers) {
|
|
|
416
414
|
realHeaders[k1] = headers[k];
|
|
417
415
|
}
|
|
418
416
|
else {
|
|
417
|
+
if (/Cookie/i.test(k)) {
|
|
418
|
+
hasCookie = true;
|
|
419
|
+
if (isEmpty(headers[k])) {
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
422
|
+
_headers.Cookie = headers[k];
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
419
425
|
_headers[k] = headers[k];
|
|
420
426
|
}
|
|
421
427
|
}
|
|
422
428
|
}
|
|
429
|
+
if (_cookies && !hasCookie) {
|
|
430
|
+
_headers.Cookie = _cookies;
|
|
431
|
+
}
|
|
423
432
|
};
|
|
424
433
|
var _headers = {};
|
|
425
434
|
if (/^[mc]/i.test(method)) {
|
|
@@ -524,7 +533,14 @@ cross_.bind = function () {
|
|
|
524
533
|
setHost,
|
|
525
534
|
addReform,
|
|
526
535
|
addDirect,
|
|
527
|
-
getCrossUrl
|
|
536
|
+
getCrossUrl,
|
|
537
|
+
// 之前一直以为中国习是中国走向衰败的罪魁祸首,可是随着了解的史料越来越多,越发觉得之前以为的是错的,中国习不过是泱泱赤匪的一个代表,赤匪从根上就是长了四只脚的土匪,他们任人唯亲,见利忘义,睚眦必报,是盘踞在华夏大地的邪恶力量的化身。他们不辨是非,做事一轰而上,唯上级马屁是瞻,遇到问题首先想到的是封锁消息,问题爆发又会选择性失聪,顾左右而言其他。
|
|
538
|
+
// 赤匪犯境时,河南大学为了保护师资,举校万里迁徙,赤匪看不见这其中的民族大义,篡权后将将北大清华那种墙头草视为香饽饽,倾斜各种资源重点培养,助长他们的墙头草作风。你看那清华北大,为国外培养了多少高科技人才啊,他们之前是墙头草,如今也还是墙头草。
|
|
539
|
+
// 儿时那清凉可口的井水,如今散发着浓郁的农药味。儿时那干净透亮的空气,晴天可以看到白云,阴天可以看到乌云,晚上还有月牙和群星同晖,如今已长年雾蒙蒙一片。可怜我华夏大地被赤匪汲取精华拱手送人,忍受各国糟粕还要强颜欢笑。
|
|
540
|
+
get: cross_.bind(null, 'GET'),
|
|
541
|
+
post: cross_.bind(null, 'POST'),
|
|
542
|
+
put: cross_.bind(null, 'PUT'),
|
|
543
|
+
delete: cross_.bind(null, 'DELETE'),
|
|
528
544
|
});
|
|
529
545
|
return cross_;
|
|
530
546
|
}
|
package/coms/pivot/checkGeo.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
return async function (a) {
|
|
2
2
|
var ip = a.ip || a.remote;
|
|
3
3
|
var m = /(\d+\.){3}\d+$/.exec(ip);
|
|
4
|
-
var
|
|
5
|
-
|
|
4
|
+
var res = await data.from("iplocation", { ip: m ? m[0] : ip });
|
|
5
|
+
if (res.data) res = res.data;
|
|
6
|
+
if (res.address) res = res.address;
|
|
7
|
+
else if (res.country || res.isp) {
|
|
8
|
+
res = [res.country, res.province, res.city, res.district, res.isp].join(' ');
|
|
9
|
+
}
|
|
10
|
+
a.address = res;
|
|
6
11
|
}
|
package/coms/zimoli/api.js
CHANGED
package/coms/zimoli/render.js
CHANGED
|
@@ -604,9 +604,8 @@ class Model {
|
|
|
604
604
|
var getValue = target.getValue;
|
|
605
605
|
var setValue = target.setValue;
|
|
606
606
|
if (getValue && setValue);
|
|
607
|
-
else if ('value' in target) {
|
|
608
|
-
|
|
609
|
-
if (!getValue) getValue = gtValue;
|
|
607
|
+
else if ('value' in target && setValue) {
|
|
608
|
+
getValue = gtValue;
|
|
610
609
|
}
|
|
611
610
|
else if (/^input$/i.test(target.tagName) && /^checkbox$/i.test(target.type) || /^checkbox$/i.test(target.tagName)) {
|
|
612
611
|
if (!getValue) getValue = gtChecked;
|
|
@@ -45,7 +45,7 @@ function 函数帧(p1, p2, point) {
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
var targetWidth = innerWidth;
|
|
48
|
-
var unitFloatReg = /^(\d+(?:\.\d+)?|\.\d+)([^\d]*)$/;
|
|
48
|
+
var unitFloatReg = /^[\+\-]?(\d+(?:\.\d+)?|\.\d+)([^\d]*)$/;
|
|
49
49
|
function 单位帧(u1, u2, point) {
|
|
50
50
|
var m1 = unitFloatReg.exec(u1);
|
|
51
51
|
if (!m1) return u1;
|
|
@@ -68,6 +68,9 @@ function 值帧(k, v1, v2, point) {
|
|
|
68
68
|
if (/color|background/.test(k)) {
|
|
69
69
|
return 颜色帧(v1, v2, point);
|
|
70
70
|
}
|
|
71
|
+
if (/opacity/.test(k)) {
|
|
72
|
+
return 浮点帧(v1, v2, Math.abs(point));
|
|
73
|
+
}
|
|
71
74
|
if (/\(/.test(v1)) {
|
|
72
75
|
return 函数帧(v1, v2, point);
|
|
73
76
|
}
|
package/coms/zimoli/zimoli.js
CHANGED
|
@@ -14,57 +14,36 @@ var pagehash_reg = /#([\/\w\:@\.\_\(\)\+\-\*\$@!~_'\?,&~%]+)$/;
|
|
|
14
14
|
var locationInitHash = location.hash;
|
|
15
15
|
var isFirstTimeLoad = sessionInitHash === null;
|
|
16
16
|
var isSimpleRefresh = sessionInitHash === locationInitHash;
|
|
17
|
-
var isWithHashLoad = !!location.hash;
|
|
18
17
|
var preventNextHashChange = false;
|
|
19
18
|
window_history.scrollRestoration = 'manual';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
var popupHashlessPath = '/';
|
|
20
|
+
var pathFromHash = function (targetHash) {
|
|
21
|
+
var targetHashIndex = targetHash.indexOf("#" + current_history);
|
|
22
|
+
if (targetHashIndex < 0) return;
|
|
23
|
+
var targetpath = targetHash.slice(targetHashIndex + current_history.replace(/\/$/, '').length + 1);
|
|
24
|
+
targetpath = decodeURI(targetpath);
|
|
25
|
+
return targetpath;
|
|
23
26
|
}
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
css(frame, "display:none");
|
|
37
|
-
appendChild.insert(body, frame);
|
|
38
|
-
var doc = frame.contentWindow.document;
|
|
39
|
-
var backman = function (isloaded) {
|
|
40
|
-
doc.open();
|
|
41
|
-
doc.write(isloaded !== false ? "" : "<script>result=parent.onhistorychange();onload=function(){history.forward()}</script>");
|
|
42
|
-
doc.close();
|
|
43
|
-
};
|
|
44
|
-
backman(false);
|
|
45
|
-
backman();
|
|
46
|
-
} else {
|
|
47
|
-
onhashchange(window, function (event) {
|
|
48
|
-
if (fixurl.ing) return;
|
|
49
|
-
// 如果是返回事件,一定不是第一次改变hash
|
|
50
|
-
// 这里刚好可以屏蔽首次手动改变url可能产生的hashchange事件
|
|
51
|
-
var targetHash = location.hash;
|
|
52
|
-
sessionStorage.setItem(sessionSavedHashKey, targetHash);
|
|
53
|
-
if (pagehash_reg.test(targetHash)) {
|
|
54
|
-
var currentHash = getCurrentHash();
|
|
55
|
-
if (currentHash && currentHash === targetHash) return;
|
|
56
|
-
var targetHashIndex = targetHash.indexOf("#" + current_history);
|
|
57
|
-
if (targetHashIndex < 0) return;
|
|
58
|
-
var targetpath = targetHash.slice(targetHashIndex + current_history.replace(/\/$/, '').length + 1);
|
|
59
|
-
targetpath = decodeURI(targetpath);
|
|
60
|
-
go(targetpath);
|
|
27
|
+
onhashchange(window, function (event) {
|
|
28
|
+
if (preventNextHashChange) return preventNextHashChange = false;
|
|
29
|
+
// 如果是返回事件,一定不是第一次改变hash
|
|
30
|
+
// 这里刚好可以屏蔽首次手动改变url可能产生的hashchange事件
|
|
31
|
+
var targetHash = location.hash;
|
|
32
|
+
sessionStorage.setItem(sessionSavedHashKey, targetHash);
|
|
33
|
+
if (pagehash_reg.test(targetHash)) {
|
|
34
|
+
var currentHash = getCurrentHash();
|
|
35
|
+
if (currentHash && currentHash === targetHash) return;
|
|
36
|
+
var targetpath = pathFromHash(targetHash);
|
|
37
|
+
if (pathFromHash(currentHash) === popupHashlessPath) {
|
|
38
|
+
backward();
|
|
61
39
|
return;
|
|
62
40
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
41
|
+
forward(targetpath);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
event.preventDefault();
|
|
45
|
+
backward();
|
|
46
|
+
});
|
|
68
47
|
// body
|
|
69
48
|
var location_pathname = location.pathname;
|
|
70
49
|
var _zimoli_params_key = `_zimoli_parameters:${location_pathname}#`;
|
|
@@ -113,8 +92,8 @@ function go(pagepath, args, history_name, oldpagepath) {
|
|
|
113
92
|
if (isNumber(pagepath)) {
|
|
114
93
|
if (isString(history_name)) {
|
|
115
94
|
var _history = history[history_name] || [];
|
|
116
|
-
pagepath = _history[pagepath <
|
|
117
|
-
oldpagepath = _history[_history.
|
|
95
|
+
pagepath = _history[pagepath < 2 ? _history.index + pagepath : pagepath];
|
|
96
|
+
oldpagepath = _history[_history.index];
|
|
118
97
|
if (arguments.length === 1) {
|
|
119
98
|
args = getZimoliParams(pagepath).data;
|
|
120
99
|
}
|
|
@@ -171,7 +150,7 @@ function go(pagepath, args, history_name, oldpagepath) {
|
|
|
171
150
|
addGlobal(_page, history_name, isRecover);
|
|
172
151
|
page_object.prepares.splice(0, page_object.prepares.length).forEach(function (url) {
|
|
173
152
|
if (isNumber(url)) {
|
|
174
|
-
url = _history[url <
|
|
153
|
+
url = _history[url < 2 ? _history.index + url : url];
|
|
175
154
|
}
|
|
176
155
|
if (isString(url)) prepare(url);
|
|
177
156
|
});
|
|
@@ -427,15 +406,30 @@ function create(pagepath, args, from, needroles) {
|
|
|
427
406
|
return _page;
|
|
428
407
|
|
|
429
408
|
}
|
|
430
|
-
|
|
409
|
+
var createEmptyHistory = function (emptyState) {
|
|
410
|
+
var h = [emptyState];
|
|
411
|
+
h.index = 0;
|
|
412
|
+
return h;
|
|
413
|
+
}
|
|
431
414
|
var zimoliid = 0, zimoliad = 0;
|
|
432
415
|
function zimoli(pagepath, args, history_name, oldpagepath) {
|
|
433
416
|
if (arguments.length === 0) {
|
|
434
417
|
if (zimoliid !== zimoliad) return;
|
|
435
418
|
history_name = current_history;
|
|
436
|
-
var _history = history[history_name] ||
|
|
437
|
-
root_path = _history[0]
|
|
438
|
-
pagepath =
|
|
419
|
+
var _history = history[history_name] || createEmptyHistory('/main');
|
|
420
|
+
root_path = _history[0];
|
|
421
|
+
pagepath = location.hash;
|
|
422
|
+
if (pagepath) {
|
|
423
|
+
pagepath = pathFromHash(pagepath);
|
|
424
|
+
if (pagepath === popupHashlessPath) {
|
|
425
|
+
preventNextHashChange = true;
|
|
426
|
+
window_history.go(-1);
|
|
427
|
+
preventNextHashChange = true;
|
|
428
|
+
pagepath = pathFromHash(location.hash);
|
|
429
|
+
}
|
|
430
|
+
if (_history.index === 0) pagepath = '';
|
|
431
|
+
}
|
|
432
|
+
if (!pagepath) pagepath = _history[_history.index];
|
|
439
433
|
try {
|
|
440
434
|
var saveddata = JSAM.parse(hostoryStorage.getItem(_zimoli_params_key + pagepath)) || {};
|
|
441
435
|
} catch (e) {
|
|
@@ -448,8 +442,6 @@ function zimoli(pagepath, args, history_name, oldpagepath) {
|
|
|
448
442
|
if (isNode(history_name))
|
|
449
443
|
var zid = history_name.zimoliid = (history_name.zimoliid | 0) + 1;
|
|
450
444
|
else var zid = arguments.length ? ++zimoliid : zimoliid;
|
|
451
|
-
|
|
452
|
-
if (page_generators[pagepath]) return go(pagepath, args, history_name, oldpagepath);
|
|
453
445
|
return prepare(pagepath, function () {
|
|
454
446
|
if (isNode(history_name)) {
|
|
455
447
|
if (history_name.zimoliid !== zid) return;
|
|
@@ -460,7 +452,7 @@ function zimoli(pagepath, args, history_name, oldpagepath) {
|
|
|
460
452
|
var global = {};
|
|
461
453
|
var history = {};
|
|
462
454
|
var current_history, default_history = current_history = "";
|
|
463
|
-
history[current_history] =
|
|
455
|
+
history[current_history] = createEmptyHistory('/main');
|
|
464
456
|
var history_session_object_key = `_zimoli_history_key:${location_pathname}`;
|
|
465
457
|
try {
|
|
466
458
|
history = JSAM.parse(hostoryStorage.getItem(history_session_object_key)) || history;
|
|
@@ -474,18 +466,25 @@ var pushstate = function (path_name, history_name) {
|
|
|
474
466
|
}
|
|
475
467
|
if (!isString(history_name)) return;
|
|
476
468
|
if (!history[history_name]) {
|
|
477
|
-
history[history_name] =
|
|
469
|
+
history[history_name] = createEmptyHistory(path_name);
|
|
478
470
|
} else {
|
|
479
471
|
var _history = history[history_name];
|
|
480
|
-
|
|
472
|
+
var prevIndex = _history.index;
|
|
473
|
+
for (var cx = 0, dx = _history.index + 1; cx < dx; cx++) {
|
|
481
474
|
if (_history[cx] === path_name) {
|
|
482
|
-
_history.
|
|
475
|
+
_history.index = cx;
|
|
483
476
|
isBack = cx < dx - 1;
|
|
484
477
|
break;
|
|
485
478
|
}
|
|
486
479
|
}
|
|
487
|
-
_history.
|
|
488
|
-
|
|
480
|
+
if (_history.index !== cx) {
|
|
481
|
+
_history.index++;
|
|
482
|
+
}
|
|
483
|
+
if (_history[_history.index] !== path_name) {
|
|
484
|
+
_history.splice(_history.index, _history.length - _history.index);
|
|
485
|
+
_history[_history.index] = path_name;
|
|
486
|
+
}
|
|
487
|
+
if (_history.index >= 0) fixurl(_history.index - prevIndex);
|
|
489
488
|
}
|
|
490
489
|
hostoryStorage.setItem(history_session_object_key, JSAM.stringify(history) || null);
|
|
491
490
|
return isBack;
|
|
@@ -495,38 +494,47 @@ var popstate = function (path_name, history_name) {
|
|
|
495
494
|
if (!isString(history_name)) return;
|
|
496
495
|
if (!history[history_name]) return;
|
|
497
496
|
var _history = history[history_name];
|
|
498
|
-
for (var cx = 0, dx = _history.
|
|
497
|
+
for (var cx = 0, dx = _history.index; cx < dx; cx++) {
|
|
499
498
|
if (_history[cx] === path_name) {
|
|
500
|
-
_history.
|
|
499
|
+
_history.index = cx;
|
|
501
500
|
break;
|
|
502
501
|
}
|
|
503
502
|
}
|
|
504
503
|
};
|
|
505
504
|
var getCurrentHash = function () {
|
|
506
|
-
var _historylist = history[current_history] || [];
|
|
507
505
|
var history_name = current_history.replace(/\/$/, '');
|
|
508
506
|
if (rootElements.length) {
|
|
509
|
-
return `#${history_name}
|
|
507
|
+
return `#${history_name}${popupHashlessPath}`;
|
|
510
508
|
}
|
|
511
|
-
|
|
512
|
-
|
|
509
|
+
var _historylist = history[current_history];
|
|
510
|
+
if (!_historylist || _historylist.index < 1) return "";
|
|
511
|
+
var targeturl = `#${history_name}${_historylist.length ? _historylist[_historylist.index] : ""}`;
|
|
513
512
|
return encodeURI(targeturl);
|
|
514
513
|
};
|
|
515
514
|
|
|
516
|
-
var fixurl = function () {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
if (pagehash_reg.test(
|
|
522
|
-
|
|
523
|
-
if (
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
515
|
+
var fixurl = function (historyDelta) {
|
|
516
|
+
preventNextHashChange = false;
|
|
517
|
+
var hash = getCurrentHash();
|
|
518
|
+
if (pagehash_reg.test(hash)) {
|
|
519
|
+
hash = location.href.replace(/\#[\s\S]*$/, '') + hash;
|
|
520
|
+
if (!pagehash_reg.test(location.href)) location.href = hash;
|
|
521
|
+
else if (location.href !== hash) {
|
|
522
|
+
if (historyDelta) {
|
|
523
|
+
preventNextHashChange = true;
|
|
524
|
+
window_history.go(historyDelta);
|
|
525
|
+
preventNextHashChange = false;
|
|
526
|
+
if (location.href !== hash) {
|
|
527
|
+
location.href = hash;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
else if (location.href !== hash) location.href = hash;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
else if (pagehash_reg.test(location.hash)) {
|
|
534
|
+
preventNextHashChange = true;
|
|
535
|
+
window_history.go(-1);
|
|
536
|
+
preventNextHashChange = false;
|
|
537
|
+
}
|
|
530
538
|
};
|
|
531
539
|
var checkonback = function (elements) {
|
|
532
540
|
for (var cx = 0, dx = elements.length; cx < dx; cx++) {
|
|
@@ -545,8 +553,19 @@ var checkonback = function (elements) {
|
|
|
545
553
|
put(":empty", function () {
|
|
546
554
|
return null;
|
|
547
555
|
});
|
|
548
|
-
|
|
549
|
-
var
|
|
556
|
+
var forward = function (pgpath) {
|
|
557
|
+
var hty = history[current_history];
|
|
558
|
+
if (hty[hty.index + 1] === pgpath) {
|
|
559
|
+
go(1);
|
|
560
|
+
}
|
|
561
|
+
else if (hty[hty.index - 1] === pgpath) {
|
|
562
|
+
backward();
|
|
563
|
+
}
|
|
564
|
+
else {
|
|
565
|
+
go(pgpath);
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
var backward = function () {
|
|
550
569
|
if (rootElements.length) {
|
|
551
570
|
var onback = checkonback(rootElements.slice(rootElements.length - 1));
|
|
552
571
|
fixurl();
|
|
@@ -632,7 +651,7 @@ var _switch = zimoli.switch = function (history_name = default_history, target_b
|
|
|
632
651
|
}
|
|
633
652
|
if (target_body) body = target_body;
|
|
634
653
|
}
|
|
635
|
-
if (emptyState !== false && !history[current_history]) root_path = (history[current_history] =
|
|
654
|
+
if (emptyState !== false && !history[current_history]) root_path = (history[current_history] = createEmptyHistory(emptyState))[0];
|
|
636
655
|
};
|
|
637
656
|
popup.global = zimoli.global = addGlobal;
|
|
638
657
|
popup.go = zimoli.go = go;
|
|
@@ -666,7 +685,7 @@ zimoli.setStorage = function (storage) {
|
|
|
666
685
|
};
|
|
667
686
|
zimoli.register = function (pathlike) {
|
|
668
687
|
var params = [];
|
|
669
|
-
pathlike = pathlike.replace(/\/\:(
|
|
688
|
+
pathlike = pathlike.replace(/\/\:([^\/\:\-]+)/g, function (_, id) {
|
|
670
689
|
params.push(id);
|
|
671
690
|
return '';
|
|
672
691
|
});
|
|
@@ -677,64 +696,100 @@ zimoli.clearHistory = function () {
|
|
|
677
696
|
history = {};
|
|
678
697
|
};
|
|
679
698
|
zimoli.getCurrentHistory = function () {
|
|
680
|
-
if (!history[current_history]) history[current_history] =
|
|
699
|
+
if (!history[current_history]) history[current_history] = createEmptyHistory();
|
|
681
700
|
return history[current_history];
|
|
682
701
|
};
|
|
683
702
|
zimoli.inithash = locationInitHash;
|
|
684
703
|
zimoli.createState = createState;
|
|
704
|
+
var touchEnabled = false;
|
|
685
705
|
zimoli.enableTouchBack = function () {
|
|
686
|
-
|
|
706
|
+
if (touchEnabled) return;
|
|
707
|
+
touchEnabled = true;
|
|
708
|
+
var backwardTarget, forwardTarget, currentTarget, history_name, historyList;
|
|
687
709
|
var touchId = 0;
|
|
688
710
|
var ratio = 0;
|
|
689
711
|
var deltaX = 0;
|
|
690
712
|
bindtouch(body, {
|
|
691
713
|
start(event) {
|
|
692
714
|
event.preventDefault();
|
|
715
|
+
touchId++;
|
|
693
716
|
ratio = null;
|
|
694
717
|
},
|
|
695
718
|
move(a, event) {
|
|
696
719
|
event.preventDefault();
|
|
697
720
|
if (a !== null) {
|
|
721
|
+
ratio = a.x / body.clientWidth;
|
|
722
|
+
if (ratio <= -1) ratio = -0.999;
|
|
723
|
+
if (ratio >= 1) ratio = 0.999;
|
|
698
724
|
if (!currentTarget) {
|
|
699
|
-
var id = ++touchId;
|
|
700
725
|
history_name = current_history;
|
|
701
726
|
historyList = history[history_name];
|
|
702
727
|
if (historyList.length < 2) return;
|
|
703
|
-
var path1 = historyList[historyList.length - 1];
|
|
704
|
-
var path0 = historyList[historyList.length - 2];
|
|
705
728
|
currentTarget = global[history_name];
|
|
729
|
+
}
|
|
730
|
+
if (ratio > 0) a: {
|
|
731
|
+
if (backwardTarget) break a;
|
|
732
|
+
var id = ++touchId;
|
|
733
|
+
if (historyList.index < 1) return;
|
|
734
|
+
var path1 = historyList[historyList.index];
|
|
735
|
+
var path0 = historyList[historyList.index - 1];
|
|
706
736
|
prepare(path0, function () {
|
|
707
737
|
if (id !== touchId) return;
|
|
708
738
|
var args = getZimoliParams(path0).data;
|
|
709
|
-
|
|
710
|
-
setWithStyle(
|
|
711
|
-
appendChild.insert(body,
|
|
739
|
+
backwardTarget = create(path0, args, path1);
|
|
740
|
+
setWithStyle(backwardTarget, true);
|
|
741
|
+
appendChild.insert(body, backwardTarget);
|
|
712
742
|
});
|
|
743
|
+
if (forwardTarget) remove(forwardTarget, false), forwardTarget = null;
|
|
744
|
+
}
|
|
745
|
+
else if (ratio < 0) a: {
|
|
746
|
+
if (forwardTarget) break a;
|
|
747
|
+
var id = ++touchId;
|
|
748
|
+
if (historyList.index >= historyList.length - 1) return;
|
|
749
|
+
var path2 = historyList[historyList.index + 1];
|
|
750
|
+
prepare(path2, function () {
|
|
751
|
+
if (id !== touchId) return;
|
|
752
|
+
var args = getZimoliParams(path2).data;
|
|
753
|
+
forwardTarget = create(path2, args, path1);
|
|
754
|
+
setWithStyle(forwardTarget, false);
|
|
755
|
+
appendChild.insert(body, forwardTarget);
|
|
756
|
+
});
|
|
757
|
+
if (backwardTarget) remove(backwardTarget, false), backwardTarget = null;
|
|
713
758
|
}
|
|
714
|
-
ratio = a.x / body.clientWidth;
|
|
715
|
-
if (ratio <= 0) ratio = 0.001;
|
|
716
|
-
if (ratio >= 1) ratio = 0.999;
|
|
717
759
|
deltaX = a.deltax;
|
|
718
760
|
transition(currentTarget, ratio);
|
|
719
|
-
transition(
|
|
761
|
+
if (backwardTarget) transition(backwardTarget, ratio - 1);
|
|
762
|
+
if (forwardTarget) transition(forwardTarget, ratio + 1);
|
|
720
763
|
}
|
|
721
764
|
return { x: ratio * body.clientWidth };
|
|
722
765
|
},
|
|
723
766
|
end() {
|
|
724
|
-
if (ratio === null
|
|
725
|
-
if (deltaX > 0 && ratio > .1 || deltaX < 0 && ratio > .9 || deltaX === 0 && ratio > .4) {
|
|
726
|
-
|
|
767
|
+
if (ratio === null) return;
|
|
768
|
+
if (historyList.index >= 1 && (deltaX > 0 && ratio > .1 || deltaX < 0 && ratio > .9 || deltaX === 0 && ratio > .4)) {
|
|
769
|
+
setWithStyle(currentTarget, true);
|
|
770
|
+
pushstate(historyList[historyList.index - 1], history_name);
|
|
771
|
+
remove(currentTarget);
|
|
772
|
+
remove(forwardTarget, false);
|
|
773
|
+
transition(backwardTarget, 1);
|
|
774
|
+
global[history_name] = backwardTarget;
|
|
775
|
+
}
|
|
776
|
+
else if (historyList.index < historyList.length - 1 && (deltaX < 0 && ratio < -.1 || deltaX > 0 && ratio < -.9 || deltaX === 0 && ratio < -.4)) {
|
|
777
|
+
pushstate(historyList[historyList.index + 1], history_name);
|
|
778
|
+
setWithStyle(currentTarget, false);
|
|
727
779
|
remove(currentTarget);
|
|
728
|
-
|
|
729
|
-
|
|
780
|
+
remove(backwardTarget, false);
|
|
781
|
+
transition(forwardTarget, 1);
|
|
782
|
+
global[history_name] = forwardTarget;
|
|
730
783
|
}
|
|
731
784
|
else {
|
|
732
|
-
setWithStyle(
|
|
733
|
-
remove(
|
|
785
|
+
if (backwardTarget) setWithStyle(backwardTarget, false), remove(backwardTarget);
|
|
786
|
+
if (forwardTarget) setWithStyle(forwardTarget, true), remove(forwardTarget);
|
|
734
787
|
transition(currentTarget, 1);
|
|
735
788
|
}
|
|
736
789
|
currentTarget = null;
|
|
737
|
-
|
|
790
|
+
backwardTarget = null;
|
|
791
|
+
historyList = null;
|
|
792
|
+
forwardTarget = null;
|
|
738
793
|
ratio = null;
|
|
739
794
|
}
|
|
740
795
|
}, 'x')
|