efront 3.22.2 → 3.22.5
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/auth/login.html +3 -0
- package/apps/pivot/auth/login.js +1 -1
- package/apps/pivot/auth/login.less +16 -3
- package/apps/pivot/log/boot.js +3 -2
- package/coms/basic/[]map.js +1 -1
- package/coms/frame/list.less +6 -4
- package/coms/layer/glance.js +4 -2
- package/coms/zimoli/autodragchildren.js +46 -35
- package/coms/zimoli/drag.js +1 -1
- package/coms/zimoli/gallery.js +1 -1
- package/coms/zimoli/getGenerator.js +4 -2
- package/coms/zimoli/list.js +31 -22
- package/coms/zimoli/menu.js +1 -3
- package/coms/zimoli/menuList.js +12 -16
- package/coms/zimoli/on.js +12 -0
- package/coms/zimoli/once.js +9 -7
- package/coms/zimoli/pagination.html +1 -1
- package/coms/zimoli/pagination.js +9 -24
- package/coms/zimoli/pagination.less +34 -19
- package/coms/zimoli/render.js +11 -1
- package/coms/zimoli/resize.js +3 -1
- package/coms/zimoli/scrollbar.js +5 -5
- package/coms/zimoli/table.html +24 -10
- package/coms/zimoli/table.js +270 -61
- package/coms/zimoli/table.less +76 -34
- package/coms/zimoli/table_test.html +32 -0
- package/coms/zimoli/table_test.js +1 -8
- package/coms/zimoli/vbox.js +25 -17
- package/coms/zimoli/vscroll.js +4 -4
- package/package.json +1 -1
- package/public/efront.js +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function main(element) {
|
|
2
|
-
var page = element ||
|
|
2
|
+
var page = element || document.createElement('pagination');
|
|
3
3
|
page.innerHTML = pagination;
|
|
4
4
|
render(page, {
|
|
5
5
|
xlist: list,
|
|
@@ -7,26 +7,10 @@ function main(element) {
|
|
|
7
7
|
fromPixel,
|
|
8
8
|
pages: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
|
|
9
9
|
next() {
|
|
10
|
-
|
|
11
|
-
index += 10;
|
|
12
|
-
if (this.pages.length < index + 10) {
|
|
13
|
-
index = this.pages.length - 10;
|
|
14
|
-
}
|
|
15
|
-
if (index < 0) {
|
|
16
|
-
index = 0;
|
|
17
|
-
}
|
|
18
|
-
this.pglist.go(index);
|
|
10
|
+
this.pglist.scrollBy(this.pglist.clientWidth);
|
|
19
11
|
},
|
|
20
12
|
prev() {
|
|
21
|
-
|
|
22
|
-
index -= 10;
|
|
23
|
-
if (this.pages.length < index + 10) {
|
|
24
|
-
index = this.pages.length - 10;
|
|
25
|
-
}
|
|
26
|
-
if (index < 0) {
|
|
27
|
-
index = 0;
|
|
28
|
-
}
|
|
29
|
-
this.pglist.go(index);
|
|
13
|
+
this.pglist.scrollBy(-this.pglist.clientWidth);
|
|
30
14
|
},
|
|
31
15
|
start() {
|
|
32
16
|
this.pglist.go(0);
|
|
@@ -39,10 +23,11 @@ function main(element) {
|
|
|
39
23
|
this.pglist.go(index);
|
|
40
24
|
}
|
|
41
25
|
});
|
|
42
|
-
|
|
43
|
-
page
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
26
|
+
var pglist = page.querySelector('xlist');
|
|
27
|
+
onmounted(page, function () {
|
|
28
|
+
console.log(pglist)
|
|
29
|
+
pglist.XScrollBoxId = 1;
|
|
30
|
+
pglist.go(0);
|
|
31
|
+
});
|
|
47
32
|
return page;
|
|
48
33
|
}
|
|
@@ -1,26 +1,41 @@
|
|
|
1
|
+
*{
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
}
|
|
1
4
|
& {
|
|
2
5
|
white-space: nowrap;
|
|
6
|
+
display: block;
|
|
7
|
+
min-width: 240px;
|
|
8
|
+
width: 100%;
|
|
9
|
+
position: relative;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
>xlist {
|
|
3
13
|
display: inline-block;
|
|
14
|
+
text-overflow: clip;
|
|
15
|
+
text-align: center;
|
|
16
|
+
position: relative;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
vertical-align: top;
|
|
19
|
+
border-left: 72px solid transparent;
|
|
20
|
+
border-right: 72px solid transparent;
|
|
21
|
+
margin: 0 -72px 0 -72px;
|
|
4
22
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
display: inline-block;
|
|
8
|
-
text-overflow: clip;
|
|
9
|
-
min-width: 40px;
|
|
10
|
-
text-align: center;
|
|
11
|
-
max-width: 400px;
|
|
12
|
-
position: relative;
|
|
13
|
-
overflow: hidden;
|
|
14
|
-
vertical-align: top;
|
|
23
|
+
.button {
|
|
24
|
+
border-radius: 0;
|
|
15
25
|
}
|
|
26
|
+
}
|
|
16
27
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
btn.button {
|
|
29
|
+
box-shadow: none;
|
|
30
|
+
padding: 0 10px;
|
|
31
|
+
min-width: 36px;
|
|
32
|
+
height: 28px;
|
|
33
|
+
line-height: 28px;
|
|
34
|
+
color: #999;
|
|
35
|
+
margin: 0;
|
|
36
|
+
vertical-align: top;
|
|
37
|
+
display: inline-block;
|
|
38
|
+
background-color: inherit;
|
|
39
|
+
color: inherit;
|
|
40
|
+
z-index: 1;
|
|
26
41
|
}
|
package/coms/zimoli/render.js
CHANGED
|
@@ -564,7 +564,17 @@ var createEmiter = function (on) {
|
|
|
564
564
|
search[0] += `with(this.$parentScopes[${scopes.length}])`;
|
|
565
565
|
getter1 = createGetter(search, false);
|
|
566
566
|
}
|
|
567
|
-
|
|
567
|
+
var onkey;
|
|
568
|
+
if (key === 'mounted' || key === 'mount') {
|
|
569
|
+
onkey = on === once ? oncemount : onmounted;
|
|
570
|
+
}
|
|
571
|
+
else if (key === 'wheel' || key === 'mousewheel') {
|
|
572
|
+
onkey = on === once ? once.emit.bind(null, onmousewheel) : onmousewheel;
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
onkey = on(key);
|
|
576
|
+
}
|
|
577
|
+
onkey(this, function (e) {
|
|
568
578
|
digest();
|
|
569
579
|
if (parsedSrc) {
|
|
570
580
|
var target = e.currentTarget || e.target;
|
package/coms/zimoli/resize.js
CHANGED
|
@@ -160,8 +160,10 @@ resize.on = function (elem, dragHandle) {
|
|
|
160
160
|
if (!~resizingElements.indexOf(elem)) {
|
|
161
161
|
resizingElements.push(elem);
|
|
162
162
|
}
|
|
163
|
-
|
|
163
|
+
resizeh.call(elem);
|
|
164
164
|
});
|
|
165
|
+
bind('render')(elem, resizeh);
|
|
166
|
+
bind('resize')(elem, resizeh);
|
|
165
167
|
on('remove')(elem, function () {
|
|
166
168
|
var index = resizingElements.indexOf(this);
|
|
167
169
|
if (~index) resizingElements.splice(index, 1);
|
package/coms/zimoli/scrollbar.js
CHANGED
|
@@ -86,7 +86,7 @@ var scrollbary = function () {
|
|
|
86
86
|
var run = function () {
|
|
87
87
|
var thumbPosition = getScreenPosition(scroller.thumb);
|
|
88
88
|
if (delta > 0 && thumbPosition.bottom - delta / 6 < scrollTimerTarget || delta < 0 && thumbPosition.top - delta / 6 > scrollTimerTarget) {
|
|
89
|
-
var targetTop = scroller
|
|
89
|
+
var targetTop = scroller.$Top() + delta;
|
|
90
90
|
var target = scroller.target;
|
|
91
91
|
scroller.scrollTo(targetTop);
|
|
92
92
|
if (target) setTargetTop(target, targetTop);
|
|
@@ -126,11 +126,11 @@ var scrollbary = function () {
|
|
|
126
126
|
|
|
127
127
|
|
|
128
128
|
var setTargetTop = function (target, top) {
|
|
129
|
-
if (target
|
|
129
|
+
if (target.$Top instanceof Function) target.$Top(top);
|
|
130
130
|
else target.scrollTop = top;
|
|
131
131
|
};
|
|
132
132
|
var getTargetTop = function (target) {
|
|
133
|
-
if (target
|
|
133
|
+
if (target.$Top instanceof Function) return target.$Top();
|
|
134
134
|
return target.scrollTop;
|
|
135
135
|
};
|
|
136
136
|
|
|
@@ -152,7 +152,7 @@ var scrollbary = function () {
|
|
|
152
152
|
_scrollbar.autoshow();
|
|
153
153
|
});
|
|
154
154
|
on("change")(_scrollbar, function () {
|
|
155
|
-
var top = _scrollbar
|
|
155
|
+
var top = _scrollbar.$Top();
|
|
156
156
|
setTargetTop(_container, top);
|
|
157
157
|
});
|
|
158
158
|
if (followResize) on("resize")(followResize, _scrollbar.reshape);
|
|
@@ -167,7 +167,7 @@ var scrollbary = function () {
|
|
|
167
167
|
_scrollbar.scrollTo = scrollTo;
|
|
168
168
|
var _handler = document.createElement("scrollbar-thumb");
|
|
169
169
|
_handler.className = "thumb";
|
|
170
|
-
_scrollbar
|
|
170
|
+
_scrollbar.$Top = getTop;
|
|
171
171
|
_scrollbar.autohide = lazy(function () {
|
|
172
172
|
this.thumb.style.opacity = 0;
|
|
173
173
|
}, 600);
|
package/coms/zimoli/table.html
CHANGED
|
@@ -1,18 +1,32 @@
|
|
|
1
|
-
<
|
|
2
|
-
<tr
|
|
3
|
-
<td row-index>序号</td>
|
|
4
|
-
<td -repeat="f in fields track by f.id" :style="{width:f.width}" @dblclick="sort(f)"><i
|
|
5
|
-
-class="f.icon"></i
|
|
1
|
+
<thead @mounted="setFixedColumn.call(this.parentNode)">
|
|
2
|
+
<tr inline-block #adapter thead @mounted="resizeT(this)">
|
|
3
|
+
<td fixed row-index>序号</td>
|
|
4
|
+
<td fixed:="f.fixed" -repeat="f in fields track by f.id" :style="{width:f.width}" @dblclick="sort(f)"><i
|
|
5
|
+
-if="f.icon" -class="f.icon"></i><span -if="f.name" -html="f.name"></span><template
|
|
6
|
+
-else> </template>
|
|
6
7
|
</td>
|
|
7
8
|
</tr>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
</thead>
|
|
10
|
+
<tbody -src="(d,i) in data" :style="tbodyHeight(this)">
|
|
11
|
+
<tr inline-block @mounted="this.style.width=adapter.style.width">
|
|
12
|
+
<td fixed row-index -bind="i+1" @mounted="this.style=adapter.firstChild.getAttribute('style')">
|
|
13
|
+
</td>
|
|
14
|
+
<td fixed:="f.fixed" -repeat="(f,i) in fields"
|
|
15
|
+
@mounted="this.style=adapter.children[i+1].getAttribute('style')">
|
|
16
|
+
<model -if="f.key&&!isEmpty(d[f.key])" :field=f :data=d readonly></model>
|
|
17
|
+
<template -else> </template>
|
|
12
18
|
<a on-click="o.do(d)" -if="!f.key&&f.options&&(!o.when||o.when(d))"
|
|
13
19
|
_type="o.type instanceof Function?o.type(d):o.type" -repeat="o in f.options">
|
|
14
20
|
<span -text="o.name instanceof Function?o.name(d):o.name"></span>
|
|
15
21
|
</a>
|
|
16
22
|
</td>
|
|
17
23
|
</tr>
|
|
18
|
-
</tbody>
|
|
24
|
+
</tbody>
|
|
25
|
+
<tfoot>
|
|
26
|
+
<tr -if="!data||!data.length" style="padding-bottom: 20px;">
|
|
27
|
+
<td style="text-align: center;">
|
|
28
|
+
<template -if="data.is_loading">加载中</template>
|
|
29
|
+
<template -else>无数据</template>
|
|
30
|
+
</td>
|
|
31
|
+
</tr>
|
|
32
|
+
</tfoot>
|
package/coms/zimoli/table.js
CHANGED
|
@@ -12,16 +12,15 @@ var moveMargin = function (element, movePixels) {
|
|
|
12
12
|
marginRight: movePixels ? -movePixels + "px" : ""
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
|
-
|
|
16
15
|
var markRowTds = function (tr, deltas, colstart, colend) {
|
|
17
16
|
var inc = 0;
|
|
18
17
|
var collections = [];
|
|
19
|
-
|
|
18
|
+
Array.prototype.forEach.call(tr.children, function (td) {
|
|
20
19
|
while (deltas[inc] > 0) {
|
|
21
20
|
deltas[inc++]--;
|
|
22
21
|
}
|
|
23
|
-
var colspan =
|
|
24
|
-
var rowspan =
|
|
22
|
+
var colspan = getColspan(td);
|
|
23
|
+
var rowspan = getRowspan(td);
|
|
25
24
|
rowspan = rowspan > 1 ? rowspan - 1 : 0;
|
|
26
25
|
colspan = colspan > 1 ? colspan - 1 : 0;
|
|
27
26
|
for (var cx = inc, dx = colspan + inc; cx <= dx; cx++) {
|
|
@@ -40,39 +39,121 @@ var markRowTds = function (tr, deltas, colstart, colend) {
|
|
|
40
39
|
});
|
|
41
40
|
return collections;
|
|
42
41
|
};
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (trElementReg.test(tr.tagName)) {
|
|
48
|
-
var collections = markRowTds(tr, savedRowDeltas, start, end);
|
|
49
|
-
savedCollections.push(collections);
|
|
42
|
+
var forEachRow = function (tbody, call) {
|
|
43
|
+
for (var tr of tbody.children) {
|
|
44
|
+
if (isTableRow(tr)) {
|
|
45
|
+
call(tr);
|
|
50
46
|
}
|
|
51
47
|
else {
|
|
52
|
-
var
|
|
53
|
-
savedCollections.push.apply(savedCollections, collections);
|
|
48
|
+
for (var c of tr.children) if (isTableRow(c)) call(c);
|
|
54
49
|
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
var getRowsOfTdsByCol = function (table, start, end) {
|
|
53
|
+
var savedCollections = [];
|
|
54
|
+
var thead = getThead(table);
|
|
55
|
+
var tbody = getTbody(table);
|
|
56
|
+
var savedRowDeltas;
|
|
57
|
+
if (thead) savedRowDeltas = [], forEachRow(thead, function (tr) {
|
|
58
|
+
var collections = markRowTds(tr, savedRowDeltas, start, end);
|
|
59
|
+
savedCollections.push(collections);
|
|
60
|
+
});
|
|
61
|
+
if (tbody) savedRowDeltas = [], forEachRow(tbody, function (tr) {
|
|
62
|
+
var collections = markRowTds(tr, savedRowDeltas, start, end);
|
|
63
|
+
savedCollections.push(collections);
|
|
55
64
|
});
|
|
56
65
|
return savedCollections;
|
|
57
66
|
}
|
|
58
67
|
var getTdsByCol = function (table, start, end) {
|
|
59
68
|
return [].concat.apply([], getRowsOfTdsByCol(table, start, end));
|
|
60
69
|
};
|
|
70
|
+
var resizeT = function (t, w) {
|
|
71
|
+
if (!w) {
|
|
72
|
+
var w = 0;
|
|
73
|
+
for (var cx = 0, dx = t.children.length; cx < dx; cx++) {
|
|
74
|
+
w += t.children[cx].offsetWidth;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
css(t, { width: w });
|
|
78
|
+
}
|
|
79
|
+
var getThead = function (table) {
|
|
80
|
+
for (var c of table.children) {
|
|
81
|
+
if (/^thead$/i.test(c.tagName) || c.hasAttribute('thead')) return c;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var getTbody = function (table) {
|
|
85
|
+
for (var c of table.children) {
|
|
86
|
+
if (/^tbody$/i.test(c.tagName) || c.hasAttribute("tbody")) return c;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
var getTfoot = function (table) {
|
|
90
|
+
for (var c of table.children) {
|
|
91
|
+
if (/^tfoot$/i.test(c.tagName) || c.hasAttribute("tfoot")) return c;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
var isTableRow = function (e) {
|
|
95
|
+
return trElementReg.test(e.tagName);
|
|
96
|
+
};
|
|
97
|
+
var getRowspan = function (e) {
|
|
98
|
+
return +e.getAttribute('rowspan') || 1;
|
|
99
|
+
};
|
|
100
|
+
var getColspan = function (e) {
|
|
101
|
+
return +e.getAttribute('colspan') || 1;
|
|
102
|
+
}
|
|
103
|
+
var resizeColumn = function (target, targetW) {
|
|
104
|
+
var deltaW = targetW - target.offsetWidth;
|
|
105
|
+
forEachRow(this, function (tr) {
|
|
106
|
+
resizeT(tr, tr.offsetWidth + deltaW);
|
|
107
|
+
});
|
|
108
|
+
for (var c of this.children) {
|
|
109
|
+
if (!isTableRow(c)) {
|
|
110
|
+
var tr = c.querySelector('tr');
|
|
111
|
+
if (!tr) continue;
|
|
112
|
+
c.style.width = tr.style.width;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
var { colstart, colend } = target;
|
|
116
|
+
if (isEmpty(colstart) || isEmpty(colend)) return;
|
|
117
|
+
var ts = getRowsOfTdsByCol(this, colstart, colend);
|
|
118
|
+
for (var cs of ts) {
|
|
119
|
+
var c = cs[cs.length - 1];
|
|
120
|
+
var w = 0;
|
|
121
|
+
for (var c of cs) {
|
|
122
|
+
w += c.offsetWidth;
|
|
123
|
+
}
|
|
124
|
+
if (!cs.length) continue;
|
|
125
|
+
w = targetW - w;
|
|
126
|
+
while (w !== 0) {
|
|
127
|
+
var c = cs.pop();
|
|
128
|
+
var w0 = c.offsetWidth + w;
|
|
129
|
+
if (w0 < 0) {
|
|
130
|
+
w = -w0;
|
|
131
|
+
w0 = w;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
w = 0;
|
|
135
|
+
}
|
|
136
|
+
if (targetW !== w) css(c, { width: w0 });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
};
|
|
61
140
|
var resizeTarget = function (event) {
|
|
62
141
|
var { resizing } = this;
|
|
63
142
|
if (!resizing) return;
|
|
64
143
|
event.moveLocked = true;
|
|
65
144
|
var { restX, target } = resizing;
|
|
66
|
-
var
|
|
67
|
-
|
|
145
|
+
var targetW = event.clientX - restX;
|
|
146
|
+
if (targetW < 20) targetW = 20;
|
|
147
|
+
resizeColumn.call(this, target, targetW);
|
|
68
148
|
resizing.clientX = event.clientX;
|
|
149
|
+
setFixedColumn.call(this);
|
|
69
150
|
};
|
|
70
151
|
var getFirstSingleColCell = function (table, col) {
|
|
71
152
|
var tds = getTdsByCol(table, col, col);
|
|
72
153
|
while (tds.length) {
|
|
73
154
|
var td = tds.shift();
|
|
74
|
-
var colspan = td
|
|
75
|
-
if (1 ===
|
|
155
|
+
var colspan = getColspan(td);
|
|
156
|
+
if (1 === colspan) return td;
|
|
76
157
|
}
|
|
77
158
|
}
|
|
78
159
|
var adaptTarget = function (event) {
|
|
@@ -122,7 +203,7 @@ function enrichField(f) {
|
|
|
122
203
|
}
|
|
123
204
|
else switch (f.type) {
|
|
124
205
|
case "text":
|
|
125
|
-
width =
|
|
206
|
+
width = 200;
|
|
126
207
|
break;
|
|
127
208
|
case "input":
|
|
128
209
|
width = 200;
|
|
@@ -144,92 +225,214 @@ function enrichField(f) {
|
|
|
144
225
|
}
|
|
145
226
|
if (width > 600) width = 600;
|
|
146
227
|
f.width = width + 60;
|
|
228
|
+
if (!f.key && f.options && isEmpty(f.fixed)) {
|
|
229
|
+
f.fixed = true;
|
|
230
|
+
}
|
|
147
231
|
}
|
|
232
|
+
var tbodyHeight = function (tbody) {
|
|
233
|
+
return { 'max-height': ((innerHeight - getScreenPosition(tbody).top - 8) / 36 | 0) * 36 }
|
|
234
|
+
};
|
|
148
235
|
|
|
236
|
+
var setFixed = function (children, scrolled, left, borderRight) {
|
|
237
|
+
var setBorderRight = function (fixedLeft) {
|
|
238
|
+
var end = fixedLeft[fixedLeft.length - 1];
|
|
239
|
+
if (end && end.style[left]) css(end, {
|
|
240
|
+
[borderRight]: '1px solid #0006'
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
var fixedElements = [];
|
|
244
|
+
var offset = 0;
|
|
245
|
+
var fixedWidth = 0;
|
|
246
|
+
for (var c of children) {
|
|
247
|
+
var pc = getScreenPosition(c);
|
|
248
|
+
var isfixed = c.hasAttribute('fixed');
|
|
249
|
+
if (fixedWidth + scrolled > offset && fixedWidth + pc.width < this.clientWidth / 3) {
|
|
250
|
+
if (isfixed) {
|
|
251
|
+
css(c, { [left]: scrolled - offset + fixedWidth, [borderRight]: '' });
|
|
252
|
+
fixedElements.push(c);
|
|
253
|
+
fixedWidth += pc.width;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
setBorderRight(fixedElements);
|
|
258
|
+
if (isfixed && c.style[left]) {
|
|
259
|
+
css(c, { [left]: '', [borderRight]: '' })
|
|
260
|
+
fixedElements.push(c);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
offset += pc.width;
|
|
264
|
+
}
|
|
265
|
+
setBorderRight(fixedElements);
|
|
266
|
+
for (var f of fixedElements) {
|
|
267
|
+
var cols = getRowsOfTdsByCol(this, f.colstart, f.colend);
|
|
268
|
+
for (var c of cols) css(c[0], {
|
|
269
|
+
[left]: f.style[left],
|
|
270
|
+
[borderRight]: f.style[borderRight]
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
var setFixedColumn = function () {
|
|
278
|
+
var thead = getThead(this);
|
|
279
|
+
if (!thead) return;
|
|
280
|
+
if (!isTableRow(thead)) thead = thead.querySelector('tr');
|
|
281
|
+
var children = Array.prototype.slice.call(thead.children);
|
|
282
|
+
var lastChild = children[children.length - 1];
|
|
283
|
+
if (!lastChild) return;
|
|
284
|
+
var deltaW = thead.scrollWidth - lastChild.offsetWidth;
|
|
285
|
+
if (this.clientWidth > deltaW + 200) {
|
|
286
|
+
css(lastChild, { width: this.clientWidth - deltaW });
|
|
287
|
+
css(thead, { width: this.clientWidth });
|
|
288
|
+
resizeColumn.call(this, lastChild, this.clientWidth - deltaW);
|
|
289
|
+
}
|
|
290
|
+
setFixed.call(this, children, this.scrollLeft, 'left', 'borderRight');
|
|
291
|
+
setFixed.call(this, children.reverse(), this.scrollWidth - this.clientWidth - this.scrollLeft, 'right', 'borderLeft');
|
|
292
|
+
var tfoot = getTfoot(this);
|
|
293
|
+
if (tfoot) {
|
|
294
|
+
css(tfoot, { left: this.scrollLeft });
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
var setClass = function (tds, cls, old) {
|
|
298
|
+
tds.forEach(td => td[cls] = true);
|
|
299
|
+
old.forEach(td => { if (!td[cls]) removeClass(td, cls) });
|
|
300
|
+
tds.forEach(td => { addClass(td, cls); delete td[cls] });
|
|
301
|
+
};
|
|
302
|
+
var getTdsOfSameRow = function (td) {
|
|
303
|
+
var tds = [td];
|
|
304
|
+
var tmp = td;
|
|
305
|
+
var rowspan = getRowspan(td);
|
|
306
|
+
var { colstart, colend } = td;
|
|
307
|
+
while (tmp) {
|
|
308
|
+
tmp = tmp.previousElementSibling;
|
|
309
|
+
if (!tmp) break;
|
|
310
|
+
if (colstart - tmp.colend > 1) break;
|
|
311
|
+
if (getRowspan(tmp) > rowspan) break;
|
|
312
|
+
tds.push(tmp);
|
|
313
|
+
colstart = tmp.colstart;
|
|
314
|
+
};
|
|
315
|
+
tmp = td;
|
|
316
|
+
while (tmp) {
|
|
317
|
+
tmp = tmp.nextElementSibling;
|
|
318
|
+
if (!tmp) break;
|
|
319
|
+
if (tmp.colstart - colend > 1) break;
|
|
320
|
+
if (getRowspan(tmp) > rowspan) break;
|
|
321
|
+
tds.push(tmp);
|
|
322
|
+
colend = tmp.colend;
|
|
323
|
+
}
|
|
324
|
+
var tr = td.parentNode;
|
|
325
|
+
while (rowspan > 1) {
|
|
326
|
+
tr = tr.nextElementSibling;
|
|
327
|
+
if (!tr) break;
|
|
328
|
+
for (var c of tr.children) {
|
|
329
|
+
if (c.colstart >= colstart && c.colend <= colend) {
|
|
330
|
+
if (getRowspan(c) <= rowspan) {
|
|
331
|
+
tds.push(c);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
rowspan--;
|
|
336
|
+
}
|
|
337
|
+
return tds;
|
|
338
|
+
};
|
|
149
339
|
function table(elem) {
|
|
150
340
|
var tableElement = isElement(elem) ? elem : document.createElement("table");
|
|
151
341
|
var activeCols = [];
|
|
152
|
-
|
|
153
|
-
var off;
|
|
154
|
-
tableElement.init = function () {
|
|
155
|
-
off = on("mousemove")(window, adaptCursor);
|
|
156
|
-
};
|
|
157
|
-
tableElement.dispose = tableElement.destroy = function () {
|
|
158
|
-
off();
|
|
159
|
-
};
|
|
160
|
-
on("append")(tableElement, tableElement.init);
|
|
161
|
-
on("remove")(tableElement, tableElement.destroy);
|
|
162
|
-
if (isMounted(tableElement)) tableElement.init();
|
|
163
|
-
|
|
342
|
+
bind('mousemove')(tableElement, adaptTarget);
|
|
164
343
|
moveupon(tableElement, {
|
|
165
344
|
start(event) {
|
|
166
345
|
if (this.resizing) event.preventDefault();
|
|
167
346
|
},
|
|
168
347
|
move: resizeTarget,
|
|
169
348
|
});
|
|
349
|
+
var activeRows = [];
|
|
170
350
|
onmousemove(tableElement, function (event) {
|
|
351
|
+
if (table.resizing) return;
|
|
352
|
+
var tbody = getTbody(table);
|
|
353
|
+
a: if (tbody) {
|
|
354
|
+
var tr = getTargetIn(tbody, event.target, false);
|
|
355
|
+
if (!tr) break a;
|
|
356
|
+
var td = getTargetIn(tr, event.target, false);
|
|
357
|
+
if (!td) break a;
|
|
358
|
+
var tds = getTdsOfSameRow(td);
|
|
359
|
+
setClass(tds, 'x-ing', activeRows);
|
|
360
|
+
activeRows = tds;
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
171
363
|
if (!thead) {
|
|
172
|
-
|
|
173
|
-
if (!thead) thead = table.querySelector('[thead]');
|
|
364
|
+
thead = getThead(table);
|
|
174
365
|
}
|
|
175
366
|
if (!getTargetIn(thead, event.target)) return;
|
|
176
|
-
|
|
177
367
|
var tds = getTargetIn(cellMatchManager, event.target);
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
td.ying = true;
|
|
181
|
-
});
|
|
182
|
-
activeCols.map(function (td) {
|
|
183
|
-
if (!td.ying) removeClass(td, "y-ing");
|
|
184
|
-
});
|
|
185
|
-
activeCols = tds.map(function (td) {
|
|
186
|
-
addClass(td, "y-ing");
|
|
187
|
-
delete td.ying;
|
|
188
|
-
return td;
|
|
189
|
-
});
|
|
368
|
+
setClass(tds, 'y-ing', activeCols);
|
|
369
|
+
activeCols = tds;
|
|
190
370
|
});
|
|
191
371
|
onmouseleave(tableElement, function () {
|
|
192
|
-
activeCols.
|
|
372
|
+
activeCols.forEach(function (td) {
|
|
193
373
|
removeClass(td, "y-ing");
|
|
194
374
|
});
|
|
375
|
+
activeRows.forEach(function (td) {
|
|
376
|
+
removeClass(td, 'x-ing');
|
|
377
|
+
});
|
|
195
378
|
});
|
|
196
379
|
var table = tableElement;
|
|
197
380
|
var thead;
|
|
381
|
+
var markedRows = false;
|
|
198
382
|
var cellMatchManager = function (element) {
|
|
199
|
-
if (!thead)
|
|
200
|
-
[thead] = table.getElementsByTagName("thead");
|
|
201
|
-
if (!thead) thead = table.querySelector('[thead]');
|
|
202
|
-
}
|
|
203
|
-
if (table.resizing) return false;
|
|
383
|
+
if (!thead) thead = getThead(table);
|
|
204
384
|
if (!getTargetIn(thead, element)) return false;
|
|
205
385
|
if (!tdElementReg.test(element.tagName)) return false;
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
386
|
+
if (!markedRows) {
|
|
387
|
+
var savedRowDeltas = [];
|
|
388
|
+
Array.prototype.forEach.call(thead.children, function (tr) {
|
|
389
|
+
markRowTds(tr, savedRowDeltas);
|
|
390
|
+
});
|
|
391
|
+
markedRows = true;
|
|
392
|
+
}
|
|
210
393
|
var { colstart, colend } = element;
|
|
211
394
|
return getTdsByCol(table, colstart, colend);
|
|
212
395
|
};
|
|
213
|
-
|
|
214
|
-
|
|
396
|
+
|
|
397
|
+
table.useIncrease = false;
|
|
398
|
+
var _vbox = function () {
|
|
399
|
+
table.$Left = function (x) {
|
|
400
|
+
if (isFinite(x)) this.scrollLeft = x;
|
|
401
|
+
setFixedColumn.call(this);
|
|
402
|
+
return this.scrollLeft;
|
|
403
|
+
};
|
|
404
|
+
vbox(table, 'x');
|
|
215
405
|
};
|
|
216
|
-
var tbodyHeight = e => ({ 'max-height': ((innerHeight - getScreenPosition(table).top - 46) / 32 | 0) * 32 + 36 });
|
|
217
406
|
care(table, function ([fields, data]) {
|
|
407
|
+
if (_vbox) _vbox(), _vbox = null;
|
|
218
408
|
thead = null;
|
|
219
409
|
fields.forEach(enrichField);
|
|
220
410
|
remove(this.children);
|
|
221
411
|
this.innerHTML = template;
|
|
222
|
-
|
|
412
|
+
markedRows = false;
|
|
413
|
+
this.style.display = 'block';
|
|
223
414
|
render(this, {
|
|
224
415
|
fields,
|
|
225
|
-
|
|
416
|
+
isEmpty,
|
|
417
|
+
tbody(e) {
|
|
226
418
|
var e = list.apply(null, arguments);
|
|
227
|
-
css(e, tbodyHeight());
|
|
419
|
+
css(e, tbodyHeight(e));
|
|
420
|
+
css(e, { width: this.adapter.offsetWidth, display: 'block' });
|
|
228
421
|
return e;
|
|
229
422
|
},
|
|
423
|
+
thead(t) {
|
|
424
|
+
var tr = document.createElement('thead');
|
|
425
|
+
tr.renders = [function () {
|
|
426
|
+
resizeT(this.firstChild)
|
|
427
|
+
}];
|
|
428
|
+
css(tr, { display: 'block' });
|
|
429
|
+
appendChild(tr, Array.prototype.slice.call(t.children));
|
|
430
|
+
return tr;
|
|
431
|
+
},
|
|
230
432
|
tbodyHeight,
|
|
231
433
|
data,
|
|
232
434
|
adapter: null,
|
|
435
|
+
resizeT,
|
|
233
436
|
model,
|
|
234
437
|
sort(f) {
|
|
235
438
|
f.sign = f.sign > 0 ? -1 : 1;
|
|
@@ -245,6 +448,8 @@ function table(elem) {
|
|
|
245
448
|
css(target, { width: f.width });
|
|
246
449
|
},
|
|
247
450
|
a: button,
|
|
451
|
+
setFixedColumn,
|
|
452
|
+
pagination
|
|
248
453
|
}, this.$parentScopes.concat(this.$scope));
|
|
249
454
|
})
|
|
250
455
|
autodragchildren(
|
|
@@ -257,6 +462,7 @@ function table(elem) {
|
|
|
257
462
|
var [f] = fields.splice(src - 1, 1);
|
|
258
463
|
fields.splice(dst - 1, 0, f);
|
|
259
464
|
}
|
|
465
|
+
markedRows = false;
|
|
260
466
|
var children = parentNode.children;
|
|
261
467
|
var srcElement = children[src];
|
|
262
468
|
var dstElement = children[rel];
|
|
@@ -290,5 +496,8 @@ function table(elem) {
|
|
|
290
496
|
}
|
|
291
497
|
}
|
|
292
498
|
);
|
|
499
|
+
resizingList.set(table);
|
|
500
|
+
on("resize")(table, setFixedColumn);
|
|
501
|
+
on("scroll")(table, setFixedColumn);
|
|
293
502
|
return table;
|
|
294
503
|
}
|