efront 4.11.0 → 4.11.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/coms/basic/getName.js +4 -4
- package/coms/compile/Html.js +2 -1
- package/coms/compile/Html_test.js +6 -3
- package/coms/compile/Program.js +19 -5
- package/coms/compile//347/264/240/351/246/250.js +39 -29
- package/coms/compile//347/264/240/351/246/250_test.js +8 -3
- package/coms/docs/codecolor.js +9 -8
- package/coms/docs/codetext.xht +92 -10
- package/coms/frame/chat.js +1 -1
- package/coms/kugou/api.js +1 -1
- package/coms/kugou/player.js +3 -0
- package/coms/zimoli/addClass.js +19 -16
- package/coms/zimoli/css.js +12 -1
- package/coms/zimoli/getGenerator.js +27 -13
- package/coms/zimoli/menuList.js +29 -23
- package/coms/zimoli/on.js +8 -0
- package/coms/zimoli/removeClass.js +4 -6
- package/coms/zimoli/render.js +123 -64
- package/coms/zimoli/table.js +2 -0
- package/coms/zimoli/vbox.js +2 -1
- package/package.json +1 -1
- package/public/efront.js +1 -1
|
@@ -11,6 +11,7 @@ var cloneChildNodes = function (template) {
|
|
|
11
11
|
}
|
|
12
12
|
return cNodes;
|
|
13
13
|
}
|
|
14
|
+
|
|
14
15
|
/**
|
|
15
16
|
* @param {Element} container
|
|
16
17
|
* @param {Element|string} tagName;
|
|
@@ -22,6 +23,7 @@ var getGenerator = function (container, tagName = 'item') {
|
|
|
22
23
|
container.$generatorScopes = scopes;
|
|
23
24
|
if (container.$generator) return container.$generator;
|
|
24
25
|
var template = document.createElement(container.tagName);
|
|
26
|
+
var tagTemplate = isElement(tagName);
|
|
25
27
|
var templates = [];
|
|
26
28
|
var hasAfter = false;
|
|
27
29
|
for (let a of container.childNodes) {
|
|
@@ -42,8 +44,21 @@ var getGenerator = function (container, tagName = 'item') {
|
|
|
42
44
|
var paddingCount = [].indexOf.call(container.childNodes, c);
|
|
43
45
|
container.paddingCount = paddingCount;
|
|
44
46
|
}
|
|
47
|
+
if (tagTemplate) {
|
|
48
|
+
if (!templates.length) {
|
|
49
|
+
templates = [tagName];
|
|
50
|
+
tagTemplate = false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
45
54
|
appendChild(template, templates);
|
|
46
55
|
render.struct(templates);
|
|
56
|
+
if (tagTemplate) {
|
|
57
|
+
render.struct(tagName);
|
|
58
|
+
var template0 = templates[0];
|
|
59
|
+
template0.$struct = render.mergeStruct(tagName.$struct, template0.$struct);
|
|
60
|
+
template0.$renderid = tagName.$renderid;
|
|
61
|
+
}
|
|
47
62
|
if (templates.length) container.$template = template;
|
|
48
63
|
/**
|
|
49
64
|
* @param {number} index;
|
|
@@ -56,28 +71,24 @@ var getGenerator = function (container, tagName = 'item') {
|
|
|
56
71
|
com = container.src[index];
|
|
57
72
|
}
|
|
58
73
|
if (com === undefined) return;
|
|
59
|
-
var needSetAttr = isElement(tagName);
|
|
60
74
|
if (isNode(element));
|
|
61
75
|
else if (!template.childNodes.length) {
|
|
62
|
-
element =
|
|
63
|
-
needSetAttr = false;
|
|
76
|
+
element = document.createElement(tagName);
|
|
64
77
|
}
|
|
65
78
|
else {
|
|
66
79
|
var childNodes = cloneChildNodes(template);
|
|
67
80
|
element = childNodes[0];
|
|
68
81
|
if (childNodes.length > 1) element.with = Array.prototype.slice.call(childNodes, 1);
|
|
69
82
|
}
|
|
70
|
-
if (needSetAttr) {
|
|
71
|
-
for (var a of tagName.attributes) {
|
|
72
|
-
element.setAttribute(a.name, a.value);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
83
|
var scopes = container.$generatorScopes;
|
|
76
84
|
var parsedSrc = container.$src;
|
|
85
|
+
var wraped = undefined;
|
|
86
|
+
if (com instanceof Item) {
|
|
87
|
+
wraped = com;
|
|
88
|
+
com = com.value;
|
|
89
|
+
}
|
|
77
90
|
if (parsedSrc) {
|
|
78
|
-
var newScope = parsedSrc.createScope(com, index, index);
|
|
79
|
-
var newItem = render(element, newScope, scopes, false);
|
|
80
|
-
if (element.with) newItem.with = render(element.with, newScope, scopes, false);
|
|
91
|
+
var newScope = parsedSrc.createScope(com, index, index, wraped);
|
|
81
92
|
} else {
|
|
82
93
|
var newScope = container.src[index];
|
|
83
94
|
if (!isObject(newScope)) newScope = {
|
|
@@ -97,9 +108,12 @@ var getGenerator = function (container, tagName = 'item') {
|
|
|
97
108
|
return this.$item;
|
|
98
109
|
}
|
|
99
110
|
}
|
|
100
|
-
|
|
101
|
-
if (element.with) newItem.with = render(element.with, newScope, scopes, false);
|
|
111
|
+
if (wraped) newScope.$wraped = wraped;
|
|
102
112
|
}
|
|
113
|
+
element.$scope = newScope;
|
|
114
|
+
element.$parentScopes = scopes;
|
|
115
|
+
var newItem = render(element, newScope, scopes, false);
|
|
116
|
+
if (element.with) newItem.with = render(element.with, newScope, scopes, false);
|
|
103
117
|
return newItem;
|
|
104
118
|
};
|
|
105
119
|
};
|
package/coms/zimoli/menuList.js
CHANGED
|
@@ -123,7 +123,8 @@ function main() {
|
|
|
123
123
|
var main = this;
|
|
124
124
|
if (direction == 'y') page.ispop = true;
|
|
125
125
|
var istoolbar = direction === 't';
|
|
126
|
-
function popMenu(
|
|
126
|
+
function popMenu(target) {
|
|
127
|
+
var item = getMenu(target);
|
|
127
128
|
if (page.actived) {
|
|
128
129
|
clear();
|
|
129
130
|
page.focus();
|
|
@@ -173,7 +174,7 @@ function main() {
|
|
|
173
174
|
enterMenuEnabled = false;
|
|
174
175
|
if (page.ispop) {
|
|
175
176
|
page.setFocus(menu);
|
|
176
|
-
popMenu(menu
|
|
177
|
+
popMenu(menu);
|
|
177
178
|
}
|
|
178
179
|
}, 60);
|
|
179
180
|
on('pointerdown')(page, unblur);
|
|
@@ -181,34 +182,36 @@ function main() {
|
|
|
181
182
|
document.activeElement.blur();
|
|
182
183
|
};
|
|
183
184
|
var activeMenu = function () {
|
|
184
|
-
|
|
185
|
+
const thismenu = getMenu(this);
|
|
186
|
+
if (thismenu.line) return;
|
|
185
187
|
if (this.hasAttribute("disabled") || this.hasAttribute('line')) return;
|
|
186
|
-
var pop = active(
|
|
188
|
+
var pop = active(thismenu.value, this);
|
|
187
189
|
if (pop === false) return;
|
|
188
190
|
var root = page.root || page;
|
|
189
191
|
var istool = root.direction === 't' || root.selected
|
|
190
192
|
if (root.ispop === 1) root.ispop = false;
|
|
191
193
|
if (istool) {
|
|
192
|
-
var menu =
|
|
194
|
+
var menu = thismenu;
|
|
193
195
|
if (root.selected) root.selected.setActive(false);
|
|
194
196
|
if (root !== page) {
|
|
195
197
|
var target = root.actived.target;
|
|
196
198
|
if (isObject(menu.value)) delete menu.value.children;
|
|
197
|
-
target
|
|
198
|
-
menu
|
|
199
|
+
var targetmenu = getMenu(target);
|
|
200
|
+
targetmenu.extends(menu.value);
|
|
201
|
+
menu = targetmenu;
|
|
199
202
|
}
|
|
200
203
|
else {
|
|
201
204
|
target = this;
|
|
202
205
|
}
|
|
203
206
|
menu.setActive(true);
|
|
204
|
-
root.selected = target
|
|
207
|
+
root.selected = getMenu(target);
|
|
205
208
|
autoremove();
|
|
206
209
|
return;
|
|
207
210
|
}
|
|
208
211
|
if (page.actived && page.actived.target === this) {
|
|
209
212
|
if (mounted_menus.indexOf(page.actived) >= 0) while (mounted_menus.length && mounted_menus[mounted_menus.length - 1] !== page.actived) remove(mounted_menus.pop());
|
|
210
213
|
if (!mounted_menus.length || page === mounted_menus[mounted_menus.length - 1]) {
|
|
211
|
-
popMenu(this
|
|
214
|
+
popMenu(this, false);
|
|
212
215
|
}
|
|
213
216
|
else {
|
|
214
217
|
remove(mounted_menus.pop());
|
|
@@ -218,7 +221,7 @@ function main() {
|
|
|
218
221
|
else {
|
|
219
222
|
while (mounted_menus.length && mounted_menus[mounted_menus.length - 1] !== page) remove(mounted_menus.pop());
|
|
220
223
|
page.actived = null;
|
|
221
|
-
popMenu(this
|
|
224
|
+
popMenu(this, false);
|
|
222
225
|
if (!page.actived) {
|
|
223
226
|
autoremove();
|
|
224
227
|
}
|
|
@@ -226,7 +229,7 @@ function main() {
|
|
|
226
229
|
};
|
|
227
230
|
var pressMenu = function (event) {
|
|
228
231
|
if (event.which === 3) {
|
|
229
|
-
popMenu(this
|
|
232
|
+
popMenu(this);
|
|
230
233
|
}
|
|
231
234
|
else {
|
|
232
235
|
switchMenu.done = false;
|
|
@@ -241,7 +244,7 @@ function main() {
|
|
|
241
244
|
|
|
242
245
|
var switchMenu = lazy(function (event) {
|
|
243
246
|
if (onclick.preventClick) return;
|
|
244
|
-
popMenu(this
|
|
247
|
+
popMenu(this);
|
|
245
248
|
switchMenu.done = true;
|
|
246
249
|
}, 300);
|
|
247
250
|
var hasIcon = function () {
|
|
@@ -255,11 +258,10 @@ function main() {
|
|
|
255
258
|
};
|
|
256
259
|
var $scope = {
|
|
257
260
|
"menu-item"(e, s) {
|
|
258
|
-
if (e && s === e.$scope) s = itemName ? s[itemName] : s.
|
|
261
|
+
if (e && s === e.$scope) s = itemName ? s[itemName] : s.$item.value;
|
|
259
262
|
var a = button(
|
|
260
263
|
menuItem(e, s, this.hasIcon)
|
|
261
264
|
);
|
|
262
|
-
a.menu = s;
|
|
263
265
|
return a;
|
|
264
266
|
},
|
|
265
267
|
hasIcon: hasIcon(),
|
|
@@ -270,9 +272,9 @@ function main() {
|
|
|
270
272
|
if (!page.$src) page.$src = render.parseRepeat("m in menus");
|
|
271
273
|
var src = page.$src;
|
|
272
274
|
var itemName = src.itemName;
|
|
273
|
-
var className = `{'has-children':$
|
|
274
|
-
|
|
275
|
-
actived:$
|
|
275
|
+
var className = `{'has-children':$item.children&&$item.children.length,
|
|
276
|
+
warn:$item.warn,
|
|
277
|
+
actived:$item.isActived()
|
|
276
278
|
}`;
|
|
277
279
|
var notHidden = `!${itemName}.hidden`;
|
|
278
280
|
var ItemTemplate = document.createElement('menu-item');
|
|
@@ -281,7 +283,6 @@ function main() {
|
|
|
281
283
|
else ItemTemplate.setAttribute("on-mouseenter", `enterMenu(this)`);
|
|
282
284
|
ItemTemplate.setAttribute("e-class", className);
|
|
283
285
|
if (src.itemName) ItemTemplate.setAttribute("e-if", notHidden);
|
|
284
|
-
ItemTemplate.setAttribute("_menu", src.itemName);
|
|
285
286
|
ItemTemplate.innerHTML = menuItem.template;
|
|
286
287
|
var generator = getGenerator(page, ItemTemplate);
|
|
287
288
|
page.$generatorScopes.push($scope);
|
|
@@ -299,11 +300,15 @@ function main() {
|
|
|
299
300
|
page.$renders.unshift(function () {
|
|
300
301
|
this.$scope.hasIcon = hasIcon();
|
|
301
302
|
});
|
|
303
|
+
var getMenu = function (a) {
|
|
304
|
+
return a.$scope.$item;
|
|
305
|
+
}
|
|
302
306
|
page.open = function (a) {
|
|
303
|
-
|
|
307
|
+
var amenu = getMenu(a);
|
|
308
|
+
if (!amenu || !amenu.length) {
|
|
304
309
|
return;
|
|
305
310
|
}
|
|
306
|
-
var m = popMenu(a
|
|
311
|
+
var m = popMenu(a);
|
|
307
312
|
m.moveFocus("home");
|
|
308
313
|
};
|
|
309
314
|
page.active = function (a) {
|
|
@@ -314,8 +319,9 @@ function main() {
|
|
|
314
319
|
if (page.selected) page.selected.setActive(false);
|
|
315
320
|
var selected = null;
|
|
316
321
|
for (var e of this.children) {
|
|
317
|
-
|
|
318
|
-
|
|
322
|
+
var emenu = getMenu(e);
|
|
323
|
+
if (!emenu) continue;
|
|
324
|
+
selected = emenu.pathTo(event.value);
|
|
319
325
|
if (selected) break;
|
|
320
326
|
}
|
|
321
327
|
if (!selected) return;
|
|
@@ -326,7 +332,7 @@ function main() {
|
|
|
326
332
|
});
|
|
327
333
|
on("focused")(page, function () {
|
|
328
334
|
var focused = page.focused;
|
|
329
|
-
if (page.ispop && !page.parent) popMenu(focused
|
|
335
|
+
if (page.ispop && !page.parent) popMenu(focused, false);
|
|
330
336
|
});
|
|
331
337
|
page.openFocus = openFocus;
|
|
332
338
|
page.closeFocus = closeFocus;
|
package/coms/zimoli/on.js
CHANGED
|
@@ -118,6 +118,14 @@ var keyCodeMap = {
|
|
|
118
118
|
num: 144,
|
|
119
119
|
numlock: 144,
|
|
120
120
|
scrolllock: 145,
|
|
121
|
+
mute: 173,// 静音
|
|
122
|
+
volumedown: 174,// 音量减
|
|
123
|
+
quiet: 174,// 音量减
|
|
124
|
+
volumeup: 175,// 音量加
|
|
125
|
+
loud: 175,// 音量加
|
|
126
|
+
next: 176,// 下一首
|
|
127
|
+
prev: 177,// 上一首
|
|
128
|
+
pause: 179,// 暂停/播放
|
|
121
129
|
semicolon: 186,
|
|
122
130
|
";": 186,
|
|
123
131
|
":": 186,
|
|
@@ -6,12 +6,10 @@ function removeClass(target, classNames) {
|
|
|
6
6
|
var c = arr[cx];
|
|
7
7
|
cls[c] = true;
|
|
8
8
|
}
|
|
9
|
-
if (isString(classNames))
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
delete cls[c];
|
|
14
|
-
}
|
|
9
|
+
if (isString(classNames)) classNames = classNames.trim().split(/\s+/);
|
|
10
|
+
if (isArray(classNames)) for (var cx = 0, dx = classNames.length; cx < dx; cx++) {
|
|
11
|
+
var c = classNames[cx];
|
|
12
|
+
delete cls[c];
|
|
15
13
|
}
|
|
16
14
|
var newarr = [];
|
|
17
15
|
for (var k in cls) {
|
package/coms/zimoli/render.js
CHANGED
|
@@ -111,6 +111,7 @@ var variableReg = /([^\:\,\+\=\-\!%\^\|\/\&\*\!\;\?\>\<~\{\}\s\[\]\(\)]|\?\s*\.(
|
|
|
111
111
|
var variableOnlyReg = new RegExp(`^${variableReg.source}$`);
|
|
112
112
|
var createGetter = function (target, search, isprop = true) {
|
|
113
113
|
if (!search) return function () { };
|
|
114
|
+
if (/^\{/.test(search)) search = `(${search})`;
|
|
114
115
|
search = renderExpress(search);
|
|
115
116
|
if (isprop) return $$eval.bind(target, search, null);
|
|
116
117
|
if (variableOnlyReg.test(search)) return $$eval.bind(target, search + "(event)", null);
|
|
@@ -154,11 +155,11 @@ class Repeater {
|
|
|
154
155
|
this.trackBy = trackBy;
|
|
155
156
|
this.srcName = srcName;
|
|
156
157
|
}
|
|
157
|
-
createScope(item, k, i) {
|
|
158
|
+
createScope(item, k, i, wraped) {
|
|
158
159
|
var scope = {
|
|
159
160
|
$key: k,
|
|
160
|
-
$item: item,
|
|
161
|
-
$index: i
|
|
161
|
+
$item: wraped || item,
|
|
162
|
+
$index: i,
|
|
162
163
|
};
|
|
163
164
|
if (this.keyName !== "$key") {
|
|
164
165
|
scope[this.keyName] = k;
|
|
@@ -388,6 +389,13 @@ var parseIfWithRepeat = function (ifExpression, repeatExpression) {
|
|
|
388
389
|
};
|
|
389
390
|
};
|
|
390
391
|
|
|
392
|
+
var mountElementIds = function (element) {
|
|
393
|
+
var scope = element.$scope;
|
|
394
|
+
for (var id of element.$struct.ids) {
|
|
395
|
+
if (scope[id] && scope[id] !== element) throw new Error(i18n`同一个id不能使用两次:` + id);
|
|
396
|
+
scope[id] = element;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
391
399
|
var renderStructure = function (element) {
|
|
392
400
|
var $struct = element.$struct;
|
|
393
401
|
if ($struct.if) var { name: ifkey, key, value: ifexp } = $struct.if;
|
|
@@ -461,6 +469,37 @@ var createBinder = function (binder) {
|
|
|
461
469
|
|
|
462
470
|
}
|
|
463
471
|
}
|
|
472
|
+
var createMapper = function (write, mapper) {
|
|
473
|
+
return function (search) {
|
|
474
|
+
var getter = isArray(search) ? search.map(s => createGetter(this, s)) : createGetter(this, search);
|
|
475
|
+
var oldValue = mapper();
|
|
476
|
+
this.$renders.push(function () {
|
|
477
|
+
var value = mapper(isArray(getter) ? getter.map(g => g(this)) : getter(this));
|
|
478
|
+
var changes = getChanges(value, oldValue);
|
|
479
|
+
if (!changes) return;
|
|
480
|
+
oldValue = value;
|
|
481
|
+
var targetValue = Object.create(null);
|
|
482
|
+
for (var k in changes) {
|
|
483
|
+
targetValue[k] = !isHandled(value[k]) ? "" : value[k];
|
|
484
|
+
}
|
|
485
|
+
write(this, targetValue);
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
var createBinder2 = function (write, read) {
|
|
490
|
+
return function (search) {
|
|
491
|
+
var getter = createGetter(this, search);
|
|
492
|
+
var oldValue = isFunction(read) ? read(this) : undefined;
|
|
493
|
+
this.$renders.push(function () {
|
|
494
|
+
var value = getter(this);
|
|
495
|
+
if (shallowEqual(value, oldValue)) return;
|
|
496
|
+
var oldv = oldValue;
|
|
497
|
+
oldValue = value;
|
|
498
|
+
if (!isHandled(value)) value = '';
|
|
499
|
+
write(this, value, oldv);
|
|
500
|
+
});
|
|
501
|
+
};
|
|
502
|
+
}
|
|
464
503
|
|
|
465
504
|
var src2 = function (search) {
|
|
466
505
|
var getter = createGetter(this, search);
|
|
@@ -480,28 +519,41 @@ var src2 = function (search) {
|
|
|
480
519
|
cast(this, origin);
|
|
481
520
|
});
|
|
482
521
|
}
|
|
522
|
+
|
|
483
523
|
var directives = {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
hide: createBinder(function (elem, value) {
|
|
487
|
-
if (arguments.length === 1) return elem.style.display === 'none';
|
|
488
|
-
elem.style.display = value ? 'none' : '';
|
|
524
|
+
text: createBinder2(function (elem, value) {
|
|
525
|
+
elem.innerText = value;
|
|
489
526
|
}),
|
|
490
|
-
|
|
491
|
-
if (
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
for (var k in changed) {
|
|
500
|
-
targetValue[k] = isEmpty(value[k]) ? "" : value[k];
|
|
527
|
+
bind: createBinder2(function (elem, value) {
|
|
528
|
+
if (isNode(value) || isArray(value)) {
|
|
529
|
+
if (value !== elem.firstChild) {
|
|
530
|
+
remove(elem.childNodes);
|
|
531
|
+
appendChild(elem, value);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
else {
|
|
535
|
+
elem.innerText = value;
|
|
501
536
|
}
|
|
502
|
-
value = targetValue;
|
|
503
|
-
css(elem, value);
|
|
504
537
|
}),
|
|
538
|
+
html: createBinder2(function (elem, value) {
|
|
539
|
+
elem.innerHTML = value;
|
|
540
|
+
}),
|
|
541
|
+
hide: createBinder2(function (elem, value) {
|
|
542
|
+
var display = value ? 'none' : '';
|
|
543
|
+
var style = elem.style;
|
|
544
|
+
if (style.display !== display) style.display = display;
|
|
545
|
+
}, function (elem) {
|
|
546
|
+
return elem.style.display === 'none';
|
|
547
|
+
}),
|
|
548
|
+
show: createBinder2(function (elem, value) {
|
|
549
|
+
var display = value ? '' : 'none';
|
|
550
|
+
var style = elem.style;
|
|
551
|
+
if (style.display !== display) style.display = display;
|
|
552
|
+
}, function (elem) {
|
|
553
|
+
return elem.style.display === 'none';
|
|
554
|
+
}),
|
|
555
|
+
style: createMapper(css, css.styleToMap),
|
|
556
|
+
class: createMapper(addClass, addClass.classToMap),
|
|
505
557
|
src(src) {
|
|
506
558
|
var parsedSrc = this.$src;
|
|
507
559
|
return src2.call(this, parsedSrc && /[\{\[\s]/.test(src) ? parsedSrc.srcName : src);
|
|
@@ -557,43 +609,7 @@ var directives = {
|
|
|
557
609
|
eventsBinders.forEach(on => on(target, onchange, true));
|
|
558
610
|
},
|
|
559
611
|
|
|
560
|
-
"class"(search) {
|
|
561
|
-
var getter = createGetter(this, `(${search})`);
|
|
562
|
-
var generatedClassNames = {};
|
|
563
|
-
var oldValue;
|
|
564
|
-
this.$renders.push(function () {
|
|
565
|
-
var className = getter(this);
|
|
566
|
-
if (deepEqual(oldValue, className)) return;
|
|
567
|
-
oldValue = className;
|
|
568
|
-
var originalClassNames = [];
|
|
569
|
-
this.className.split(/\s+/).map(function (k) {
|
|
570
|
-
if (k && !hasOwnProperty.call(generatedClassNames, k) && !hasOwnProperty.call(originalClassNames, k)) {
|
|
571
|
-
if (!/^\d+$/.test(k)) originalClassNames.push(originalClassNames[k] = k);
|
|
572
|
-
}
|
|
573
|
-
});
|
|
574
|
-
var deltaClassNames = [];
|
|
575
|
-
if (isString(className)) {
|
|
576
|
-
className.split(/\s+/).map(function (k) {
|
|
577
|
-
if (!hasOwnProperty.call(originalClassNames, k)) {
|
|
578
|
-
if (!/^\d+$/.test(k)) deltaClassNames.push(deltaClassNames[k] = k);
|
|
579
|
-
}
|
|
580
|
-
});
|
|
581
|
-
} else if (isObject(className)) {
|
|
582
|
-
for (var k in className) {
|
|
583
|
-
if (!hasOwnProperty.call(originalClassNames, k) && className[k]) {
|
|
584
|
-
if (!/^\d+$/.test(k)) deltaClassNames.push(deltaClassNames[k] = k);
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
var destClassName = originalClassNames.concat(deltaClassNames).join(" ");
|
|
589
|
-
generatedClassNames = deltaClassNames;
|
|
590
|
-
if (this.className !== destClassName) {
|
|
591
|
-
this.className = destClassName;
|
|
592
|
-
}
|
|
593
|
-
});
|
|
594
|
-
},
|
|
595
612
|
};
|
|
596
|
-
directives.text = directives.bind;
|
|
597
613
|
// property binder
|
|
598
614
|
var binders = {
|
|
599
615
|
_(attr, search) {
|
|
@@ -761,15 +777,12 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
|
|
|
761
777
|
if (isEmpty(s.once)) s.once = once;
|
|
762
778
|
element.$eval = $eval;
|
|
763
779
|
}
|
|
780
|
+
mountElementIds(element);
|
|
764
781
|
if (element.$renderid <= -1) element = renderStructure(element);
|
|
765
782
|
if (!element) return;
|
|
766
783
|
if (!element || element.$renderid < 0 || element.nodeType !== 1) {
|
|
767
784
|
return element;
|
|
768
785
|
}
|
|
769
|
-
for (var id of element.$struct.ids) {
|
|
770
|
-
if (scope[id] && scope[id] !== element) throw new Error(i18n`同一个id不能使用两次:` + id);
|
|
771
|
-
scope[id] = element;
|
|
772
|
-
}
|
|
773
786
|
var isFirstRender = !element.$renderid;
|
|
774
787
|
|
|
775
788
|
if (isFirstRender) {
|
|
@@ -794,6 +807,7 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
|
|
|
794
807
|
if (!replacer.$parentScopes) replacer.$parentScopes = parentScopes;
|
|
795
808
|
if (isElement(replacer) && !replacer.$renderid) {
|
|
796
809
|
createStructure(replacer);
|
|
810
|
+
replacer.$struct = mergeStruct(element.$struct, replacer.$struct);
|
|
797
811
|
if (replacer.children && replacer.children.length) renderElement(replacer.children, replacer.$scope, replacer.$parentScopes, once);
|
|
798
812
|
renderRest(replacer, replacer.$struct);
|
|
799
813
|
replacer.$struct.ons.forEach(([on, key, value]) => on.call(replacer, replacer, key, value));
|
|
@@ -865,6 +879,44 @@ function $eval(search, scope, event) {
|
|
|
865
879
|
return $$eval.call(this, search, scope, this, event);
|
|
866
880
|
}
|
|
867
881
|
|
|
882
|
+
var merge = function (dst, src) {
|
|
883
|
+
if (!isHandled(src)) return dst;
|
|
884
|
+
if (!isHandled(dst)) return src;
|
|
885
|
+
if (isArray(dst)) {
|
|
886
|
+
return dst.concat(src);
|
|
887
|
+
}
|
|
888
|
+
if (isObject(dst)) return Object.assign(dst, src);
|
|
889
|
+
return src;
|
|
890
|
+
};
|
|
891
|
+
var pushb = function (dist, b) {
|
|
892
|
+
if (isArray(b)) dist.push(...b);
|
|
893
|
+
else if (isHandled(b)) dist.push(b);
|
|
894
|
+
};
|
|
895
|
+
var mergeStruct = function (struct1, struct2) {
|
|
896
|
+
if (!isObject(struct1)) return struct2;
|
|
897
|
+
if (!isObject(struct2)) return struct1;
|
|
898
|
+
for (var k in struct2) if (k !== 'binds') {
|
|
899
|
+
struct1[k] = merge(struct1[k], struct2[k]);
|
|
900
|
+
}
|
|
901
|
+
var binds1 = struct1.binds;
|
|
902
|
+
var binds2 = struct2.binds;
|
|
903
|
+
for (var k in binds2) {
|
|
904
|
+
if (/^(class|style)$/.test(k)) {
|
|
905
|
+
var dist = [];
|
|
906
|
+
pushb(dist, binds1[k]);
|
|
907
|
+
pushb(dist, binds2[k]);
|
|
908
|
+
if (dist.length) {
|
|
909
|
+
if (dist.length === 1) dist = dist[0];
|
|
910
|
+
binds1[k] = dist;
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
else {
|
|
914
|
+
binds1[k] = binds2[k];
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
return struct1;
|
|
918
|
+
}
|
|
919
|
+
|
|
868
920
|
class Struct {
|
|
869
921
|
constructor(ons, types, copys, binds, attrs, props, ids, once) {
|
|
870
922
|
this.ons = ons;
|
|
@@ -880,6 +932,12 @@ class Struct {
|
|
|
880
932
|
}
|
|
881
933
|
|
|
882
934
|
|
|
935
|
+
var pushid = function (ids, name) {
|
|
936
|
+
ids.push(name);
|
|
937
|
+
var name1 = name.replace(/\-([a-z])/ig, (_, a) => a.toUpperCase());
|
|
938
|
+
if (name1 !== name) ids.push(name1);
|
|
939
|
+
};
|
|
940
|
+
|
|
883
941
|
function createStructure(element) {
|
|
884
942
|
if (isArrayLike(element)) return Array.prototype.map.call(element, createStructure);
|
|
885
943
|
if (element.$struct) return element.$struct;
|
|
@@ -903,11 +961,11 @@ function createStructure(element) {
|
|
|
903
961
|
var { name, value } = attr;
|
|
904
962
|
if (/^\$/.test(name)) continue;
|
|
905
963
|
if (name === 'elementid' || name === 'renderid' || name === 'id') {
|
|
906
|
-
ids
|
|
964
|
+
pushid(ids, value);
|
|
907
965
|
continue;
|
|
908
966
|
}
|
|
909
967
|
if (/^#/.test(name)) {
|
|
910
|
-
ids
|
|
968
|
+
pushid(ids, name.slice(1));
|
|
911
969
|
element.removeAttribute(name);
|
|
912
970
|
continue;
|
|
913
971
|
};
|
|
@@ -1033,4 +1091,5 @@ render.register = function (key, name) {
|
|
|
1033
1091
|
}
|
|
1034
1092
|
};
|
|
1035
1093
|
render.getFromScopes = getFromScopes;
|
|
1036
|
-
render.struct = createStructure;
|
|
1094
|
+
render.struct = createStructure;
|
|
1095
|
+
render.mergeStruct = mergeStruct;
|
package/coms/zimoli/table.js
CHANGED
|
@@ -307,6 +307,7 @@ var setFixedColumn = function (remark) {
|
|
|
307
307
|
markRowTds(tr, remark);
|
|
308
308
|
});
|
|
309
309
|
if (!isTableRow(thead)) thead = thead.querySelector('tr');
|
|
310
|
+
if (!thead) return;
|
|
310
311
|
var children = Array.prototype.slice.call(thead.children);
|
|
311
312
|
var lastChild = children[children.length - 1];
|
|
312
313
|
var lastFieldChild = children[children.length - 2];
|
|
@@ -573,6 +574,7 @@ function table(elem) {
|
|
|
573
574
|
pagination
|
|
574
575
|
};
|
|
575
576
|
render(this, $scope, this.$parentScopes.concat(this.$scope));
|
|
577
|
+
if (isMounted(table)) setFixedColumn.call(table);
|
|
576
578
|
$scope.data = Table.from(fields, await data);
|
|
577
579
|
$scope.data.callback = function () {
|
|
578
580
|
render.digest();
|
package/coms/zimoli/vbox.js
CHANGED
|
@@ -148,8 +148,9 @@ function ybox(generator) {
|
|
|
148
148
|
wheelTime = event.timeStamp;
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
|
-
var deltay = -event.deltaY;
|
|
152
151
|
if (event.moveLocked) return;
|
|
152
|
+
var deltay = -event.deltaY;
|
|
153
|
+
if (!deltay && _box.bindX) deltay = -event.deltaX;
|
|
153
154
|
event.moveLocked = true;
|
|
154
155
|
var box;
|
|
155
156
|
if (deltay > 0) {
|