efront 4.9.4 → 4.10.1

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.
Files changed (42) hide show
  1. package/coms/basic/Item.js +6 -1
  2. package/coms/basic/Tree.js +15 -1
  3. package/coms/basic/shallowClone.js +6 -2
  4. package/coms/basic_/JSON.js +1 -5
  5. package/coms/basic_/JSON_test.js +7 -1
  6. package/coms/compile/Html_test.js +12 -1
  7. package/coms/compile/Javascript.js +94 -58
  8. package/coms/compile/Javascript_test.js +70 -2
  9. package/coms/compile/Program.js +187 -53
  10. package/coms/compile/audit.js +1 -1
  11. package/coms/compile/autoenum.js +1 -1
  12. package/coms/compile/cloneNode.js +2 -0
  13. package/coms/compile/common.js +74 -43
  14. package/coms/compile/downLevel.js +6 -6
  15. package/coms/compile/downLevel_test.js +5 -1
  16. package/coms/compile/formatcode.js +1 -1
  17. package/coms/compile/powermap.js +1 -1
  18. package/coms/compile/unstruct.js +2 -2
  19. package/coms/docs/codecolor.js +47 -17
  20. package/coms/docs/codetext.xht +83 -12
  21. package/coms/frame/route.js +15 -15
  22. package/coms/zimoli/XMLHttpRequest.js +2 -5
  23. package/coms/zimoli/alert.js +2 -2
  24. package/coms/zimoli/confirm.js +1 -1
  25. package/coms/zimoli/createEvent.js +6 -7
  26. package/coms/zimoli/dispatch.js +8 -4
  27. package/coms/zimoli/getScreenPosition.js +6 -6
  28. package/coms/zimoli/grid.js +14 -10
  29. package/coms/zimoli/list.js +13 -1
  30. package/coms/zimoli/on.js +2 -1
  31. package/coms/zimoli/picture.js +1 -1
  32. package/coms/zimoli/render.js +1 -1
  33. package/coms/zimoli/slider.js +4 -0
  34. package/coms/zimoli/tree.js +133 -43
  35. package/coms/zimoli/tree.less +2 -1
  36. package/coms/zimoli/vbox.js +5 -5
  37. package/coms/zimoli/vbox.less +3 -1
  38. package/coms/zimoli/zimoli.js +1 -1
  39. package/data/packexe-setup.sfx +0 -0
  40. package/docs//347/273/204/344/273/266.xht +4 -4
  41. package/package.json +1 -1
  42. package/public/efront.js +1 -1
@@ -1,8 +1,10 @@
1
1
  var getTreeFromArray = Tree.fromArray;
2
2
  function buildCrack(com, set) {
3
- var count = com.length;
4
- for (var cx = 0, dx = com.length; cx < dx; cx++) {
5
- var c = com[cx];
3
+ var coms = com;
4
+ while (coms.joined) coms = coms[0];
5
+ var count = coms.length;
6
+ for (var cx = 0, dx = coms.length; cx < dx; cx++) {
7
+ var c = coms[cx];
6
8
  if (!c.isClosed() && c.length) {
7
9
  count += buildCrack(c, false);
8
10
  }
@@ -13,23 +15,24 @@ function buildCrack(com, set) {
13
15
  return count;
14
16
  }
15
17
 
16
- function getCrackTarget(com) {
18
+ function getChildrenBottom(com) {
19
+ while (com.joined) com = com[0];
17
20
  for (var cx = com.length - 1; cx >= 0; cx--) {
18
21
  var c = com[cx];
19
22
  if (!c.isClosed() && c.length) {
20
- var t = getCrackTarget(c);
23
+ var t = getChildrenBottom(c);
21
24
  if (t) {
22
25
  return t;
23
26
  }
24
27
  }
25
- if (c.target) return c.target;
28
+ if (c.$target) return c.$target;
26
29
  }
27
- return com.target;
30
+ return com.$target;
28
31
  }
29
32
 
30
33
  var getArrayFromTree = Tree.toArray;
31
34
  var appendTo = Tree.appendTo;
32
-
35
+ var getOffset = e => getScreenPosition(e, false);
33
36
  function tree() {
34
37
  var element, generator;
35
38
  [].forEach.call(arguments, function (arg) {
@@ -52,35 +55,37 @@ function tree() {
52
55
  banner.setData(this.src);
53
56
  this.src = root;
54
57
  });
55
-
56
- var banner = list(element, function (index) {
57
- var coms = dom;
58
- if (index >= coms.length) return;
59
- var com = coms[index];
58
+ var createChild = function (com, index) {
60
59
  var span;
61
- if (!com) return;
62
- if (com.target) {
63
- com.target.index = index;
64
- com.target.refresh();
65
- return com.target;
66
- }
67
60
  var tabs = new Array(com.tab + 1).join("<t></t>");
68
61
  if (isFunction(generator)) {
69
62
  var elem = generator(index, com.constructor === Item ? com.value : com, com);
70
63
  if (!elem) return;
64
+ var c = com;
65
+ while (c.joined) {
66
+ c = c[0];
67
+ var e = generator(index, c.constructor === Item ? c.value : c, c);
68
+ appendChild(elem, e.childNodes);
69
+ }
71
70
  span = document.createElement('span');
72
71
  span.innerHTML = tabs;
73
72
  span.setAttribute("tabs", '');
74
73
  elem.insertBefore(span, elem.firstChild);
75
74
  span = elem;
76
75
  } else {
76
+ var name = c => `<c>${c.name}</c>${c.test ? "<i>_test</i>" : ""}`;
77
+ var c = com;
78
+ var names = [name(c)];
79
+ while (c.joined) {
80
+ c = c[0];
81
+ names.push(name(c));
82
+ }
77
83
  span = document.createElement("node");
78
- html(span, `<span tabs>${tabs}</span><c>${com.name}</c>${com.test ? "<i>_test</i>" : ""}<a class=count>${com.count}</a>`);
84
+ html(span, `<span tabs>${tabs}</span>${names.join('/')}<a class=count>${com.count}</a>`);
79
85
  span.count = span.lastElementChild;
80
86
  }
81
87
  var _div = button(span);
82
88
  _div.setAttribute("node", '');
83
- _div.index = index;
84
89
 
85
90
  if (!com.saved) {
86
91
  com.saved = {};
@@ -116,13 +121,13 @@ function tree() {
116
121
  }
117
122
  _div.style.zIndex = 1;
118
123
  _div.itemid = com.id;
119
- if (_div.index === changed_index) {
124
+ if (_div.$index === changed_index) {
120
125
  saved_top = _div;
121
126
  setState(true);
122
127
  } else {
123
128
  setState();
124
129
  }
125
- if (_div.index === changed_offset) {
130
+ if (_div.$index === changed_offset) {
126
131
  saved_offset = _div;
127
132
  }
128
133
  com.closed = com.isClosed();
@@ -132,33 +137,36 @@ function tree() {
132
137
  var setState = function (closed = com.isClosed()) {
133
138
  var saved = com.saved;
134
139
  if (com.length) {
135
- if (saved.closed !== closed) {
140
+
141
+ if (saved.closed !== closed || _div !== com.$target) {
136
142
  saved.closed = closed;
137
143
  if (closed) {
138
- addClass(com.target, 'closed');
139
- removeClass(com.target, 'open empty');
144
+ addClass(_div, 'closed');
145
+ removeClass(_div, 'open empty');
140
146
  } else {
141
- addClass(com.target, 'open');
142
- removeClass(com.target, 'closed empty');
147
+ addClass(_div, 'open');
148
+ removeClass(_div, 'closed empty');
143
149
  }
144
150
  }
145
151
  if (saved.empty) {
146
- removeClass(com.target, 'empty');
152
+ removeClass(_div, 'empty');
147
153
  saved.empty = false;
148
154
  }
149
155
  } else {
150
156
  if (!saved.empty) {
151
157
  saved.empty = true;
152
- addClass(com.target, 'empty');
158
+ addClass(_div, 'empty');
153
159
  }
154
160
  if (saved.closed === true || saved.closed === false) {
155
- removeClass(com.target, 'closed open');
161
+ removeClass(_div, 'closed open');
156
162
  saved.closed = null;
157
163
  }
158
164
  }
159
165
  };
160
- com.target = _div;
161
- _div.refresh();
166
+ var getChildrenTop = function (com) {
167
+ while (com.joined) com = com[0];
168
+ return com[0]?.$target;
169
+ }
162
170
  onclick(_div, function (event) {
163
171
  var isClosed = com.isClosed();
164
172
  if (!active(banner, com.value, com, banner.$src ? createItemTarget.call(banner, com.value) : _div)) {
@@ -167,24 +175,24 @@ function tree() {
167
175
  if (isClosed === com.isClosed() && com.length) {
168
176
  com.setClosed(!isClosed);
169
177
  }
170
- var index = this.index;
178
+ var index = this.$index;
171
179
  changed_index = index;
172
180
  buildCrack(com);
173
181
  changed_offset = com.crack + index;
174
182
  if (!com.length) {
175
- dom.forEach(d => d.target && d.target.refresh());
183
+ dom.forEach(d => d.$target && d.$target.refresh());
176
184
  return;
177
185
  }
178
186
  var z0 = function () {
179
187
  var z = function (e) {
180
- if (e.target) e.target.style.zIndex = 0;
188
+ if (e.$target) e.$target.style.zIndex = 0;
181
189
  if (e instanceof Array) e.forEach(z);
182
190
  };
183
191
  com.forEach(z);
184
192
  };
185
193
  var z1 = function () {
186
194
  var z = function (e) {
187
- if (e.target) e.target.style.zIndex = 1;
195
+ if (e.$target) e.$target.style.zIndex = 1;
188
196
  if (e instanceof Array) e.forEach(z);
189
197
  };
190
198
  com.forEach(z);
@@ -195,8 +203,8 @@ function tree() {
195
203
  if (com.isClosed() && com.length) {
196
204
  z0();
197
205
  setState(true);
198
- var bottom = getCrackTarget(com);
199
- var top = com[0].target;
206
+ var bottom = getChildrenBottom(com);
207
+ var top = getChildrenTop(com);
200
208
  if (!top) return refresh();
201
209
  var marginTop;
202
210
  if (!bottom || !bottom.offsetTop) {
@@ -229,11 +237,25 @@ function tree() {
229
237
  timeout(z1, res + 60);
230
238
  }
231
239
  });
232
-
240
+ return _div;
241
+ };
242
+ var banner = list(element, function (index) {
243
+ var coms = dom;
244
+ if (index >= coms.length) return;
245
+ var com = coms[index];
246
+ if (!com) return;
247
+ if (com.$target) {
248
+ com.$target.$index = index;
249
+ com.$target.refresh();
250
+ return com.$target;
251
+ }
252
+ var _div = createChild(com, index);
253
+ com.$target = _div;
254
+ _div.$index = index;
255
+ _div.refresh();
233
256
  return _div;
234
257
  });
235
258
 
236
-
237
259
  banner.setData = function (src) {
238
260
  root = new Tree(src);
239
261
  refresh();
@@ -242,14 +264,82 @@ function tree() {
242
264
  appendTo(parent, data);
243
265
  refresh();
244
266
  };
267
+ if (!('joined' in banner)) {
268
+ var joined = banner.hasAttribute("join") && !/^(false|0|null|nill?)/i.test(banner.getAttribute('join')) || banner.join;
269
+ banner.joined = joined != undefined ? joined : 7;
270
+ }
271
+ var stickys = [];
272
+ var setSticky = function () {
273
+ var p = stickys[stickys.length - 1];
274
+ var f = banner.getFirstVisibleElement(stickys.top + 1);
275
+ if (!f) return;
276
+ var limitHeight = f.offsetTop - banner.scrollTop;
277
+ var c = dom[f.$index];
278
+ var useLimit = false;
279
+ if (p) {
280
+ var d = dom[p.$index];
281
+ if (d.tab == c.tab) {
282
+ var { top, height } = getOffset(p);
283
+ if (top + height >= limitHeight) {
284
+ var ic = c.parent.indexOf(c);
285
+ useLimit = c.parent[ic - 1] === d;
286
+ if (useLimit) c = d;
287
+ }
288
+ }
289
+ else {
290
+ useLimit = true;
291
+ limitHeight += getOffset(f).height;
292
+ }
293
+ }
294
+ var parents = [];
295
+ if (c.isClosed() || !c.length) c = c.parent;
296
+ while (c.parent) {
297
+ var p = c.parent;
298
+ if (!p?.joined) {
299
+ if (!c.$target) return;
300
+ parents.push(c);
301
+ }
302
+ c = p;
303
+ }
304
+ stickys.forEach(s => s.sticky = false);
305
+ parents = parents.map(p => {
306
+ p.sticky = true;
307
+ return p.$target;
308
+ });
309
+ parents.reverse();
310
+ stickys.forEach(s => {
311
+ if (!s.sticky) {
312
+ css(s, {
313
+ position: "",
314
+ top: '',
315
+ zIndex: 1
316
+ })
317
+ }
318
+ })
319
+ stickys = parents;
320
+ var top = 0;
321
+ stickys.forEach(p => {
322
+ var h = getOffset(p).height;
323
+ var limit = useLimit && top + h > limitHeight;
324
+ css(p, {
325
+ position: 'sticky',
326
+ top: limit ? limitHeight - h : top, zIndex: 3 - limit
327
+ });
328
+ top += h;
329
+ });
330
+ stickys.top = top;
331
+ }
245
332
  var refresh = function () {
246
333
  var index = banner.index();
247
- var needremoves = dom.map(d => d.target).filter(d => !!d);
248
- dom = getArrayFromTree(root, true);
334
+ var needremoves = dom.map(d => d.$target).filter(d => !!d);
335
+ dom = getArrayFromTree(root, banner.joined);
249
336
  remove(needremoves, false);
250
337
  banner.go(index || 0);
251
338
  css(banner, { paddingBottom: '' });
339
+ setSticky();
252
340
  };
341
+ on("mounted")(banner, setSticky);
342
+ on('scroll')(banner, setSticky);
253
343
  banner.refresh = refresh;
254
344
 
255
345
  return banner;
@@ -11,6 +11,8 @@
11
11
  color: inherit;
12
12
  padding-right: 10px;
13
13
  box-shadow: none;
14
+ width: 100%;
15
+ border-radius: 0;
14
16
 
15
17
  &.line,
16
18
  &[line] {
@@ -69,7 +71,6 @@ t {
69
71
  margin-left: -.2em;
70
72
  margin-right: .2em;
71
73
  margin-top: .2em;
72
-
73
74
  border-top: .4em solid;
74
75
  border-bottom: .2em solid transparent;
75
76
  }
@@ -78,12 +78,12 @@ function ybox(generator) {
78
78
  }
79
79
  height = height * Math.pow(.92, t / 6);
80
80
  increaser.height = height
81
- increaser.style.height = fromOffset(height);
81
+ increaser.style.marginBottom = fromOffset(height);
82
82
  return height;
83
83
  }
84
84
  if (increaser.height) {
85
85
  increaser.height = 0;
86
- increaser.style.height = 0;
86
+ increaser.style.marginBottom = 0;
87
87
  return 1;
88
88
  }
89
89
  remove(increaser);
@@ -121,7 +121,7 @@ function ybox(generator) {
121
121
  increaser_b.style.marginTop = 0;
122
122
  increaser_b.style.marginBottom = 0;
123
123
  increaser_b.height = 0;
124
- increaser_b.style.height = 0;
124
+ increaser_b.style.marginBottom = 0;
125
125
  appendChild(_box, increaser_b);
126
126
  var deltaMargin = _box.scrollHeight - increaser_b.offsetTop - parseFloat(getComputedStyle(_box).paddingBottom);
127
127
  if (deltaMargin > 0) {
@@ -133,8 +133,8 @@ function ybox(generator) {
133
133
  if (t_height > increase_height) t_height = increase_height;
134
134
  if (b_height < 0) b_height = 0;
135
135
  if (t_height < 0) t_height = 0;
136
- if (!minusOnly || b_height < increaser_b.height) increaser_b.height = b_height, increaser_b.style.height = fromOffset(b_height);
137
- if (!minusOnly || t_height < increaser_t.height) increaser_t.height = t_height, increaser_t.style.height = fromOffset(t_height);
136
+ if (!minusOnly || b_height < increaser_b.height) increaser_b.height = b_height, increaser_b.style.marginBottom = fromOffset(b_height);
137
+ if (!minusOnly || t_height < increaser_t.height) increaser_t.height = t_height, increaser_t.style.marginBottom = fromOffset(t_height);
138
138
  return t_height < increase_height && b_height < increase_height;
139
139
  };
140
140
  if (/Edge|Trident/i.test(navigator.userAgent)) {
@@ -38,5 +38,7 @@
38
38
  }
39
39
 
40
40
  >.x-insert {
41
- display: inline-block;
41
+ display: block;
42
+ float: left;
43
+ height: 100%;
42
44
  }
@@ -603,7 +603,7 @@ function addGlobal(element, name = null, isDestroy) {
603
603
  }
604
604
  if (isFunction(body.layer)) {
605
605
  body.layer(element, oldElement, history);
606
- } else {
606
+ } else if (body !== element) {
607
607
  if (isDestroy || !oldElement) appendChild.insert(body, element);
608
608
  else appendChild.after(oldElement, element);
609
609
  remove(oldElement);
Binary file
@@ -70,13 +70,13 @@
70
70
  height: 100%;
71
71
  }
72
72
 
73
- [codearea]>code {
73
+ [codearea]>.codetext {
74
74
  overflow: auto;
75
75
  display: block;
76
+ white-space: pre;
76
77
  height: auto;
77
78
  min-height: 100%;
78
- padding: 10px 20px 40px 20px;
79
- white-space: nowrap;
79
+ border-width: 10px 20px 40px 20px;
80
80
  outline: none;
81
81
  }
82
82
 
@@ -380,7 +380,7 @@
380
380
  if (node) {
381
381
  var next = node.nextSibling;
382
382
  if (next) {
383
- next = /^\u2002+/.exec(next.nodeValue);
383
+ next = /^[\u2002\u0020\u00a0]+/.exec(next.nodeValue);
384
384
  if (next) return next[0].length;
385
385
  }
386
386
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.9.4",
3
+ "version": "4.10.1",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {