efront 3.18.3 → 3.19.2
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 -0
- package/apps/pivot/link/chat.js +6 -3
- package/apps/pivot/link/index.html +2 -0
- package/apps/pivot/link/index.js +13 -0
- package/apps/pivot/link/room.html +0 -0
- package/apps/pivot/link/room.js +10 -0
- package/apps/pivot/main.js +7 -1
- package/apps/pivot/menu.yml +1 -1
- package/apps/pivot/wow/edit.js +3 -0
- package/apps/pivot/wow/root.js +33 -4
- package/coms/basic/submit_.js +40 -0
- package/coms/basic/valid.js +8 -0
- package/coms/frame/chat.js +2 -1
- package/coms/random/{sfz.js → /350/272/253/344/273/275/350/257/201.js} +1 -1
- package/coms/zimoli/Item.js +32 -23
- package/coms/zimoli/contextmenu.js +5 -4
- package/coms/zimoli/drag.js +0 -1
- package/coms/zimoli/field.js +2 -0
- package/coms/zimoli/menuItem.html +1 -1
- package/coms/zimoli/menuItem.js +2 -4
- package/coms/zimoli/menuList.html +1 -1
- package/coms/zimoli/menuList.js +3 -3
- package/coms/zimoli/menuList.less +5 -0
- package/coms/zimoli/move.js +5 -23
- package/coms/zimoli/oncemount.js +1 -1
- package/coms/zimoli/render.js +36 -27
- package/coms/zimoli/resize.js +1 -4
- package/coms/zimoli/submit.js +6 -39
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/apps/pivot/api.yml
CHANGED
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
count: options ::count
|
|
15
15
|
bootlog: options ::similar
|
|
16
16
|
link: options ::link
|
|
17
|
+
room: options ::link-:id
|
|
17
18
|
care: options ::care-:id
|
|
18
19
|
cast: options ::cast-:id?:msg
|
|
20
|
+
upload: put :path
|
|
19
21
|
https://www.ip.cn/:
|
|
20
22
|
iplocation: get https://www.ip.cn/api/index?ip=:ip&type=1
|
|
21
23
|
# https://ipchaxun.com/ :
|
package/apps/pivot/link/chat.js
CHANGED
|
@@ -2,7 +2,7 @@ async function link(id, page) {
|
|
|
2
2
|
if (!id) {
|
|
3
3
|
id = await data.from("link");
|
|
4
4
|
}
|
|
5
|
-
page.$scope.title = `会话窗口(<span nodrag>${id}</span>)`;
|
|
5
|
+
if (!page.name) page.$scope.title = `会话窗口(<span nodrag>${id}</span>)`;
|
|
6
6
|
page.roomid = id;
|
|
7
7
|
var removed = false;
|
|
8
8
|
on("remove")(page, function () {
|
|
@@ -16,8 +16,11 @@ async function link(id, page) {
|
|
|
16
16
|
page.push(await xhr);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
function main(
|
|
20
|
-
var
|
|
19
|
+
function main(params) {
|
|
20
|
+
if (isObject(params)) var { linkid: id, name } = params;
|
|
21
|
+
else id = params;
|
|
22
|
+
var page = frame$chat(name);
|
|
23
|
+
if (name) page.name = name;
|
|
21
24
|
care(page, 'send', function (msg) {
|
|
22
25
|
data.from("cast", { id: page.roomid, msg });
|
|
23
26
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function index() {
|
|
2
|
+
var page = document.createElement('link-index');
|
|
3
|
+
page.innerHTML = template;
|
|
4
|
+
renderWithDefaults(page, {
|
|
5
|
+
menus: "房间 /link/room, 会话 /link/list".split(/\s*,\s*/).map(a => {
|
|
6
|
+
var [name, path] = a.split(/\s+/);
|
|
7
|
+
return { name, path };
|
|
8
|
+
}),
|
|
9
|
+
menu,
|
|
10
|
+
});
|
|
11
|
+
page.$scope.menus[0].actived = true;
|
|
12
|
+
return page;
|
|
13
|
+
}
|
|
File without changes
|
package/apps/pivot/main.js
CHANGED
|
@@ -26,7 +26,7 @@ data.bindInstance("base", async function (base) {
|
|
|
26
26
|
cross.addDirect(base.base);
|
|
27
27
|
var apimap = await data.getConfig();
|
|
28
28
|
for (var k in apimap) {
|
|
29
|
-
if (apimap[k].method
|
|
29
|
+
if (/options|put/.test(apimap[k].method)) apimap[k].base = base.base;
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
32
|
var base = data.getInstance('base').base;
|
|
@@ -53,6 +53,12 @@ var layer = layer$glance({
|
|
|
53
53
|
on("append")(layer, function () {
|
|
54
54
|
frame$route.open();
|
|
55
55
|
});
|
|
56
|
+
on("dragover")(document, function (event) {
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
});
|
|
59
|
+
on("drop")(document, function (event) {
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
});
|
|
56
62
|
function main() {
|
|
57
63
|
return layer;
|
|
58
64
|
}
|
package/apps/pivot/menu.yml
CHANGED
package/apps/pivot/wow/edit.js
CHANGED
|
@@ -10,6 +10,7 @@ function main({ path: root, name }) {
|
|
|
10
10
|
renderWithDefaults(a, {
|
|
11
11
|
fields,
|
|
12
12
|
pathlist: root,
|
|
13
|
+
origin,
|
|
13
14
|
isFolder: /\/$/.test(name),
|
|
14
15
|
data: { name: origin, origin },
|
|
15
16
|
remove() {
|
|
@@ -19,9 +20,11 @@ function main({ path: root, name }) {
|
|
|
19
20
|
on('submit')(a, async function (e) {
|
|
20
21
|
e.preventDefault();
|
|
21
22
|
var path = root.concat(a.$scope.data.name).join('/');
|
|
23
|
+
path = encode62.timeencode(path);
|
|
22
24
|
if (origin) {
|
|
23
25
|
var to = path;
|
|
24
26
|
path = origin;
|
|
27
|
+
path = encode62.timeencode(path);
|
|
25
28
|
}
|
|
26
29
|
await data.from("folder", { opt: origin ? 'mov' : 'add', path, to }).loading_promise;
|
|
27
30
|
dispatch(this, 'submited');
|
package/apps/pivot/wow/root.js
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
var fields = refilm`
|
|
2
2
|
文件
|
|
3
3
|
`;
|
|
4
|
-
|
|
4
|
+
var passport = encode62.timeencode(encode62.decode62(user._passport, user.session));
|
|
5
|
+
async function upload(f, base) {
|
|
6
|
+
var api = await data.getApi('upload');
|
|
7
|
+
var authorization = await data.getSource(api.base);
|
|
8
|
+
var xhr = cross(api.method, api.base + base + f.name, { authorization: authorization });
|
|
9
|
+
xhr.setRequestHeader('range', 'bytes=1-' + f.size);
|
|
10
|
+
return xhr.send(f);
|
|
11
|
+
}
|
|
5
12
|
function main() {
|
|
13
|
+
async function uploadAll(files) {
|
|
14
|
+
await queue.call(files, function (f) {
|
|
15
|
+
return upload(f, page.$scope.pathlist.join("/"));
|
|
16
|
+
});
|
|
17
|
+
page.$scope.open();
|
|
18
|
+
}
|
|
6
19
|
var page = div();
|
|
7
20
|
page.innerHTML = root;
|
|
8
21
|
page.onback = function () {
|
|
@@ -15,15 +28,24 @@ function main() {
|
|
|
15
28
|
return false;
|
|
16
29
|
}
|
|
17
30
|
page.setAttribute('ng-mousedown', 'setActive')
|
|
31
|
+
bind('drop')(page, async function (event) {
|
|
32
|
+
event.preventDefault();
|
|
33
|
+
var files = event.dataTransfer.files;
|
|
34
|
+
uploadAll(files);
|
|
35
|
+
});
|
|
18
36
|
|
|
19
37
|
renderWithDefaults(page, {
|
|
20
38
|
lattice,
|
|
21
39
|
pathlist: data.getInstance("pathlist"),
|
|
22
40
|
active: null,
|
|
23
41
|
open(p) {
|
|
42
|
+
if (p && !/\/$/.test(p.name)) {
|
|
43
|
+
// window.open("/" + this.pathlist.concat(p.name).join('/'))
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
24
46
|
if (p) p = String(p.name || '').replace(/\/$/, '');
|
|
25
47
|
if (p) data.setInstance("pathlist", this.pathlist.concat(p));
|
|
26
|
-
this.data = data.from("folder", { opt: 'list', path: "/" + this.pathlist.join('/') }, files => {
|
|
48
|
+
this.data = data.from("folder", { opt: 'list', path: encode62.timeencode("/" + this.pathlist.join('/')) }, files => {
|
|
27
49
|
if (files) return sortname(files).map(f => {
|
|
28
50
|
return {
|
|
29
51
|
name: f,
|
|
@@ -66,7 +88,14 @@ function main() {
|
|
|
66
88
|
}
|
|
67
89
|
},
|
|
68
90
|
{
|
|
69
|
-
name:
|
|
91
|
+
name: "添加文件",
|
|
92
|
+
when: e => !getActive(e),
|
|
93
|
+
do() {
|
|
94
|
+
return chooseFile().then(uploadAll);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: '重命名',
|
|
70
99
|
when,
|
|
71
100
|
do(e) {
|
|
72
101
|
popupEdit(e.$scope.d.name);
|
|
@@ -91,7 +120,7 @@ function main() {
|
|
|
91
120
|
}, 2000);
|
|
92
121
|
return false;
|
|
93
122
|
}
|
|
94
|
-
await data.from("folder", { opt: 'del', path: "/" + page.$scope.pathlist.concat(e.$scope.d.name).join("/") }).loading_promise;
|
|
123
|
+
await data.from("folder", { opt: 'del', path: encode62.timeencode("/" + page.$scope.pathlist.concat(e.$scope.d.name).join("/")) }).loading_promise;
|
|
95
124
|
page.$scope.open();
|
|
96
125
|
}
|
|
97
126
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
function submit(fields, data) {
|
|
2
|
+
var params = {};
|
|
3
|
+
var inputs = [];
|
|
4
|
+
var select = [];
|
|
5
|
+
var checks = [];
|
|
6
|
+
var id = 0;
|
|
7
|
+
for (var f of fields) {
|
|
8
|
+
var error = valid(f, data);
|
|
9
|
+
if (error === "empty") {
|
|
10
|
+
if (f.options instanceof Array || /date|time|range|switch|swap|radio/i.test(f.type)) {
|
|
11
|
+
if (!select.id) select.id = ++id;
|
|
12
|
+
select.push(f);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
if (!inputs.id) inputs.id = ++id;
|
|
16
|
+
inputs.push(f);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else if (error) {
|
|
20
|
+
checks.push(f);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
params[f.key] = data[f.key];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (checks.length + select.length + inputs.length) {
|
|
27
|
+
var errors = [];
|
|
28
|
+
if (inputs.length) errors.push("请输入" + inputs.map(f => f.name).join("、"));
|
|
29
|
+
if (select.length) errors.push("请选择" + select.map(f => f.name).join("、"));
|
|
30
|
+
if (select.id < inputs.id) {
|
|
31
|
+
errors = errors.reverse();
|
|
32
|
+
}
|
|
33
|
+
if (checks.length) {
|
|
34
|
+
errors.push(checks.map(f => f.name).join("、") + "格式错误");
|
|
35
|
+
}
|
|
36
|
+
errors = errors.join(",") + "!";
|
|
37
|
+
throw errors;
|
|
38
|
+
}
|
|
39
|
+
return params;
|
|
40
|
+
}
|
package/coms/basic/valid.js
CHANGED
|
@@ -6,5 +6,13 @@ function valid(field, data) {
|
|
|
6
6
|
}
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
|
+
if (field.valid instanceof Function) {
|
|
10
|
+
var e = field.valid(data[field.key]);
|
|
11
|
+
if (e) return e;
|
|
12
|
+
}
|
|
13
|
+
if (field.options instanceof Function) {
|
|
14
|
+
var e = field.options(data[field.key]);
|
|
15
|
+
if (e) return e;
|
|
16
|
+
}
|
|
9
17
|
return error;
|
|
10
18
|
}
|
package/coms/frame/chat.js
CHANGED
|
@@ -19,6 +19,7 @@ function chat(title = '会话窗口') {
|
|
|
19
19
|
page.innerHTML = template;
|
|
20
20
|
drag.on(page.firstElementChild, page);
|
|
21
21
|
resize.on(page);
|
|
22
|
+
var localid = Date.now() + Math.sin(Math.random());
|
|
22
23
|
page.push = function (msgs) {
|
|
23
24
|
var { msglist } = this.$scope;
|
|
24
25
|
msglist.push.apply(msglist, msgs);
|
|
@@ -37,7 +38,7 @@ function chat(title = '会话窗口') {
|
|
|
37
38
|
grid,
|
|
38
39
|
msglist: [],
|
|
39
40
|
text: '',
|
|
40
|
-
localid
|
|
41
|
+
localid,
|
|
41
42
|
msg,
|
|
42
43
|
remove() {
|
|
43
44
|
remove(page);
|
package/coms/zimoli/Item.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
var id = 0;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
class Item extends Array {
|
|
3
|
+
constructor(value) {
|
|
4
|
+
super();
|
|
5
|
+
this.children = this;
|
|
6
|
+
this.count = 0;//子项中的叶子节点数
|
|
7
|
+
this.total = 0;//子项中的节点数
|
|
8
|
+
this.crack = 0;
|
|
9
|
+
this.id = ++id;
|
|
10
|
+
this.extends(value);
|
|
11
|
+
}
|
|
11
12
|
extends(value) {
|
|
12
13
|
this.value = value;
|
|
13
14
|
if (value.children instanceof Array) {
|
|
@@ -16,7 +17,6 @@ Item.prototype = extend([], {
|
|
|
16
17
|
this.push.apply(this, children);
|
|
17
18
|
}
|
|
18
19
|
if (isObject(value)) {
|
|
19
|
-
this.name = value.name;
|
|
20
20
|
this.tab = value.tab;
|
|
21
21
|
this.icon = value.icon;
|
|
22
22
|
this.color = value.color;
|
|
@@ -28,30 +28,38 @@ Item.prototype = extend([], {
|
|
|
28
28
|
if (value.href) this.href = value.href;
|
|
29
29
|
if (value.src) this.src = value.src;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
this.name = value;
|
|
33
|
-
}
|
|
34
|
-
},
|
|
31
|
+
}
|
|
35
32
|
|
|
36
33
|
valueOf() {
|
|
37
34
|
return this.value;
|
|
38
|
-
}
|
|
35
|
+
}
|
|
39
36
|
toString() {
|
|
40
37
|
return String(this.value);
|
|
41
|
-
}
|
|
38
|
+
}
|
|
39
|
+
get warn() {
|
|
40
|
+
if (isObject(this.value)) {
|
|
41
|
+
return /danger|red|warn/.test(this.value.type) || this.value.warn;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
get name() {
|
|
46
|
+
if (isObject(this.value)) return this.value.name;
|
|
47
|
+
return this.value;
|
|
48
|
+
}
|
|
49
|
+
|
|
42
50
|
isClosed() {
|
|
43
51
|
return !!this.value.closed;
|
|
44
|
-
}
|
|
52
|
+
}
|
|
45
53
|
setClosed(value) {
|
|
46
54
|
this.value.closed = value;
|
|
47
|
-
}
|
|
55
|
+
}
|
|
48
56
|
isActive() {
|
|
49
57
|
if (isObject(this.value)) {
|
|
50
58
|
if ("active" in this.value) return this.value.active;
|
|
51
59
|
if ('actived' in this.value) return this.value.actived;
|
|
52
60
|
}
|
|
53
61
|
return !!this.actived;
|
|
54
|
-
}
|
|
62
|
+
}
|
|
55
63
|
setActive(value) {
|
|
56
64
|
if (isObject(this.value)) {
|
|
57
65
|
if ('active' in this.value) {
|
|
@@ -61,15 +69,16 @@ Item.prototype = extend([], {
|
|
|
61
69
|
}
|
|
62
70
|
}
|
|
63
71
|
this.actived = value;
|
|
64
|
-
}
|
|
72
|
+
}
|
|
65
73
|
isSelected() {
|
|
66
74
|
return !!this.value.selected;
|
|
67
|
-
}
|
|
75
|
+
}
|
|
68
76
|
isChecked() {
|
|
69
77
|
return !!this.value.checked;
|
|
70
|
-
}
|
|
78
|
+
}
|
|
71
79
|
getClass() {
|
|
72
80
|
return !!this.value.class;
|
|
73
81
|
}
|
|
74
|
-
|
|
82
|
+
|
|
83
|
+
}
|
|
75
84
|
Item.prototype.isActived = Item.prototype.isActive;
|
|
@@ -8,10 +8,11 @@ var createMenu = function (event, items) {
|
|
|
8
8
|
if (!item.when(event)) return false;
|
|
9
9
|
return true;
|
|
10
10
|
});
|
|
11
|
-
var elem = menuList(menulist, items,
|
|
12
|
-
|
|
13
|
-
remove(elem);
|
|
14
|
-
}
|
|
11
|
+
var elem = menuList(menulist, items, function (item) {
|
|
12
|
+
action.call(this, item, event.target).then(function (e) {
|
|
13
|
+
if (e !== false) remove(elem);
|
|
14
|
+
});
|
|
15
|
+
return false;
|
|
15
16
|
});
|
|
16
17
|
|
|
17
18
|
return elem;
|
package/coms/zimoli/drag.js
CHANGED
package/coms/zimoli/field.js
CHANGED
package/coms/zimoli/menuItem.js
CHANGED
|
@@ -8,16 +8,14 @@ function main(elem, scope, hasIcon) {
|
|
|
8
8
|
var scope = item.$scope;
|
|
9
9
|
}
|
|
10
10
|
if (scope.menu) scope = scope.menu;
|
|
11
|
-
|
|
12
|
-
var icon = scope.icon;
|
|
13
|
-
if (hasIcon === undefined) hasIcon = !!icon;
|
|
11
|
+
if (hasIcon === undefined) hasIcon = !!scope.icon;
|
|
14
12
|
if (scope.disabled || scope.enabled === false) {
|
|
15
13
|
item.setAttribute('disabled', '');
|
|
16
14
|
}
|
|
17
15
|
else {
|
|
18
16
|
item.removeAttribute("disabled");
|
|
19
17
|
}
|
|
20
|
-
render(item.children, scope, hasIcon instanceof Array ? hasIcon : [{ useIcon: hasIcon, hasIcon
|
|
18
|
+
render(item.children, scope, hasIcon instanceof Array ? hasIcon : [{ useIcon: hasIcon, hasIcon }]);
|
|
21
19
|
if (scope.line) item.setAttribute("line", ''), on("click")(item, preventDefault);
|
|
22
20
|
if (scope.hotkey) bindAccesskey(item, scope.hotkey);
|
|
23
21
|
return item;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<menu-item ng-repeat="menu in menus" ng-if="!menu.hidden" ng-click="open.call(this)" ng-mouseleave="cancel()"
|
|
2
2
|
ng-mouseenter="popMenu.call(this)" ng-mousedown="popMenu1.call(this,event)" ng-class="{'has-children':menu.children&&menu.children.length,
|
|
3
|
-
'warn':menu.
|
|
3
|
+
'warn':menu.warn,
|
|
4
4
|
'actived':menu.isActived()
|
|
5
5
|
}">
|
|
6
6
|
</menu-item>
|
package/coms/zimoli/menuList.js
CHANGED
|
@@ -226,7 +226,7 @@ function main(page, items, active, direction = 'y') {
|
|
|
226
226
|
clear();
|
|
227
227
|
clearTimeout(popTimer);
|
|
228
228
|
}
|
|
229
|
-
var fire = function () {
|
|
229
|
+
var fire = async function () {
|
|
230
230
|
cancel();
|
|
231
231
|
if (this.menu.line) return;
|
|
232
232
|
if (byMousedown) return;
|
|
@@ -297,7 +297,6 @@ function main(page, items, active, direction = 'y') {
|
|
|
297
297
|
a.menu = s;
|
|
298
298
|
return a;
|
|
299
299
|
},
|
|
300
|
-
menus: items.map(i => i instanceof Item ? i : new Item(i)),
|
|
301
300
|
hasIcon: hasIcon(),
|
|
302
301
|
open: fire,
|
|
303
302
|
cancel,
|
|
@@ -308,7 +307,7 @@ function main(page, items, active, direction = 'y') {
|
|
|
308
307
|
var src = page.$src;
|
|
309
308
|
var itemName = src.itemName;
|
|
310
309
|
var className = `{'has-children':${itemName}.children&&${itemName}.children.length,
|
|
311
|
-
'warn':${itemName}.
|
|
310
|
+
'warn':${itemName}.warn,
|
|
312
311
|
actived:${itemName}.isActived()
|
|
313
312
|
}`;
|
|
314
313
|
var notHidden = `!${itemName}.hidden`;
|
|
@@ -335,6 +334,7 @@ function main(page, items, active, direction = 'y') {
|
|
|
335
334
|
}
|
|
336
335
|
else {
|
|
337
336
|
page.innerHTML = menuList;
|
|
337
|
+
$scope.menus = items.map(i => i instanceof Item ? i : new Item(i));
|
|
338
338
|
render(page, $scope);
|
|
339
339
|
vbox(page);
|
|
340
340
|
}
|
package/coms/zimoli/move.js
CHANGED
|
@@ -152,30 +152,12 @@ var fixPosition = move.fixPosition = function (target) {
|
|
|
152
152
|
};
|
|
153
153
|
move.coordIn = coordIn;
|
|
154
154
|
move.trimCoord = trimCoord;
|
|
155
|
-
var
|
|
156
|
-
|
|
157
|
-
resizingTargets.forEach(fixPosition);
|
|
158
|
-
});
|
|
159
|
-
var off;
|
|
160
|
-
var resizeTarget = function () {
|
|
161
|
-
var target = this;
|
|
162
|
-
var index = resizingTargets.indexOf(target);
|
|
163
|
-
if (index < 0) index = resizingTargets.push(target);
|
|
164
|
-
return index;
|
|
155
|
+
var fixTarget = function () {
|
|
156
|
+
fixPosition(this);
|
|
165
157
|
};
|
|
166
|
-
var removeResize = function () {
|
|
167
|
-
removeFromList(resizingTargets, this);
|
|
168
|
-
};
|
|
169
|
-
|
|
170
158
|
move.bindPosition = function (target, position) {
|
|
171
|
-
|
|
159
|
+
oncemount(target, function () {
|
|
172
160
|
setPosition(target, position);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (index >= 0) return;
|
|
176
|
-
on("append")(target, resizeTarget);
|
|
177
|
-
on("remove")(target, removeResize);
|
|
178
|
-
if (isMounted(target)) {
|
|
179
|
-
resizeTarget.call(target);
|
|
180
|
-
}
|
|
161
|
+
});
|
|
162
|
+
on("resize")(target, fixTarget);
|
|
181
163
|
}
|
package/coms/zimoli/oncemount.js
CHANGED
package/coms/zimoli/render.js
CHANGED
|
@@ -190,7 +190,6 @@ var createRepeat = function (search, id = 0) {
|
|
|
190
190
|
var clone = element.cloneNode();
|
|
191
191
|
clone.innerHTML = element.innerHTML;
|
|
192
192
|
clone.renderid = id;
|
|
193
|
-
clone.$parentScopes = $parentScopes;
|
|
194
193
|
clone.$scope = $scope;
|
|
195
194
|
clone.$parentScopes = $parentScopes;
|
|
196
195
|
clone.$struct = $struct;
|
|
@@ -202,7 +201,7 @@ var createRepeat = function (search, id = 0) {
|
|
|
202
201
|
if (a.previousSibling !== last) appendChild.after(last, a);
|
|
203
202
|
last = a;
|
|
204
203
|
}, this);
|
|
205
|
-
cloned.forEach(a => render(a))
|
|
204
|
+
cloned.forEach(a => render(a));
|
|
206
205
|
for (var k in clonedElements) {
|
|
207
206
|
if (clonedElements1[k] !== clonedElements[k]) remove(clonedElements[k]);
|
|
208
207
|
}
|
|
@@ -214,27 +213,40 @@ var createRepeat = function (search, id = 0) {
|
|
|
214
213
|
once("append")(this, initialComment.bind(this, renders, "repeat", expression));
|
|
215
214
|
}
|
|
216
215
|
};
|
|
216
|
+
var comment = function (elements) {
|
|
217
|
+
for (var cx = elements.length - 2; cx > 1; cx -= 2) {
|
|
218
|
+
var e = elements[cx];
|
|
219
|
+
if (e.previousSibling === this) var c = this;
|
|
220
|
+
else {
|
|
221
|
+
var c = document.createComment('else' + (cx < elements.length - 2 ? "if .." : ''));
|
|
222
|
+
e.parentNode.insertBefore(c, e);
|
|
223
|
+
}
|
|
224
|
+
elements.splice(cx, 0, c);
|
|
225
|
+
remove(e);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
var initIf = function (ifs) {
|
|
229
|
+
for (var s of ifs) {
|
|
230
|
+
comment(s);
|
|
231
|
+
if (s.parent) {
|
|
232
|
+
initialComment.call(s[0], s.renders, "if", s.comment);
|
|
233
|
+
} else {
|
|
234
|
+
once("append")(s[0], initialComment.bind(s[0], s.renders, "if", s.comment));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
};
|
|
217
238
|
var createIf = function (search, id = 0) {
|
|
218
239
|
// 懒渲染
|
|
219
240
|
var getter = createGetter(search).bind(this);
|
|
220
241
|
var element = this;
|
|
221
|
-
var p = element;
|
|
222
|
-
if (p.parentNode) {
|
|
223
|
-
p = p.parentNode;
|
|
224
|
-
for (var cx = 0, dx = if_top.length; cx < dx; cx++) {
|
|
225
|
-
if (if_top[cx].parent === p) {
|
|
226
|
-
break;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
cx++;
|
|
231
|
-
if (cx > 0) if_top.splice(cx, if_top.length - cx);
|
|
232
242
|
var elements = [element, getter];
|
|
233
243
|
if_top.push(elements);
|
|
234
244
|
var savedValue;
|
|
235
|
-
|
|
245
|
+
elements.parent = this.parentNode;
|
|
246
|
+
elements.comment = search[1];
|
|
247
|
+
elements.renders = [function () {
|
|
236
248
|
var shouldMount = -1;
|
|
237
|
-
for (var cx = 0, dx = elements.length; cx < dx; cx +=
|
|
249
|
+
for (var cx = 0, dx = elements.length; cx < dx; cx += 3) {
|
|
238
250
|
var getter = elements[cx + 1];
|
|
239
251
|
if (!getter || getter()) {
|
|
240
252
|
shouldMount = cx;
|
|
@@ -243,10 +255,10 @@ var createIf = function (search, id = 0) {
|
|
|
243
255
|
}
|
|
244
256
|
if (savedValue === shouldMount) return;
|
|
245
257
|
savedValue = shouldMount;
|
|
246
|
-
for (var cx = 0, dx = elements.length; cx < dx; cx +=
|
|
258
|
+
for (var cx = 0, dx = elements.length; cx < dx; cx += 3) {
|
|
247
259
|
var element = elements[cx];
|
|
248
260
|
if (cx === shouldMount) {
|
|
249
|
-
appendChild.
|
|
261
|
+
appendChild.after(cx > 0 ? elements[cx - 1] : this, element);
|
|
250
262
|
if (element.renderid < 0) {
|
|
251
263
|
element.renderid = id;
|
|
252
264
|
elements[cx] = render(element, this.$scope, this.$parentScopes);
|
|
@@ -258,12 +270,6 @@ var createIf = function (search, id = 0) {
|
|
|
258
270
|
}
|
|
259
271
|
|
|
260
272
|
}];
|
|
261
|
-
if (this.parentNode) {
|
|
262
|
-
elements.parent = this.parentNode;
|
|
263
|
-
initialComment.call(this, renders, "if", search[1]);
|
|
264
|
-
} else {
|
|
265
|
-
once("append")(this, initialComment.bind(this, renders, "if", search[1]));
|
|
266
|
-
}
|
|
267
273
|
};
|
|
268
274
|
var parseIfWithRepeat = function (ifExpression, repeatExpression) {
|
|
269
275
|
var repeater = parseRepeat(repeatExpression);
|
|
@@ -357,15 +363,18 @@ var structures = {
|
|
|
357
363
|
createIf.call(this, search);
|
|
358
364
|
},
|
|
359
365
|
"else"(search) {
|
|
360
|
-
var
|
|
361
|
-
|
|
366
|
+
for (var cx = if_top.length - 1; cx >= 0; cx--) {
|
|
367
|
+
if (if_top[cx].parent === this.parentNode) break;
|
|
368
|
+
}
|
|
369
|
+
if (cx < 0) {
|
|
362
370
|
throw new Error("else/elseif前缺少同级if!");
|
|
363
371
|
}
|
|
372
|
+
initIf(if_top.splice(cx + 1, if_top.length - cx - 1));
|
|
373
|
+
var top = if_top[cx];
|
|
364
374
|
if (search && search[1]) {
|
|
365
375
|
var getter = createGetter(search).bind(this);
|
|
366
376
|
}
|
|
367
377
|
top.push(this, getter);
|
|
368
|
-
remove(this);
|
|
369
378
|
},
|
|
370
379
|
repeat(search) {
|
|
371
380
|
createRepeat.call(this, search);
|
|
@@ -854,7 +863,7 @@ function render(element, scope, parentScopes, lazy = true) {
|
|
|
854
863
|
renderlock = false;
|
|
855
864
|
eagermount = false;
|
|
856
865
|
}
|
|
857
|
-
if (if_top_length < if_top.length) if_top.splice(if_top_length, if_top.length - if_top_length);
|
|
866
|
+
if (if_top_length < if_top.length) initIf(if_top.splice(if_top_length, if_top.length - if_top_length));
|
|
858
867
|
return e;
|
|
859
868
|
}
|
|
860
869
|
var digest = lazy(refresh, -{});
|