efront 3.35.3 → 3.35.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.
Files changed (43) hide show
  1. package/coms/basic/#loader.js +2 -0
  2. package/coms/basic/JSAM.md +7 -0
  3. package/coms/basic/Speed.js +15 -5
  4. package/coms/basic/Speed_test.js +58 -0
  5. package/coms/basic/parseYML.md +1 -0
  6. package/coms/basic/queue.md +10 -0
  7. package/coms/basic/serialize.md +4 -0
  8. package/coms/basic/sortname.md +4 -0
  9. package/coms/basic/wait.md +7 -0
  10. package/coms/compile/Html.js +6 -3
  11. package/coms/compile/Program.js +10 -6
  12. package/coms/compile/namelist.js +1 -1
  13. package/coms/compile/richcss.js +25 -19
  14. package/coms/compile/scanner2_test.js +9 -3
  15. package/coms/docs/markdown.js +2 -2
  16. package/coms/reptile/colored_console.js +1 -1
  17. package/coms/zimoli/arriswise.md +12 -0
  18. package/coms/zimoli/autodragchildren.js +1 -0
  19. package/coms/zimoli/autodragchildren.md +12 -0
  20. package/coms/zimoli/checkbox.js +1 -1
  21. package/coms/zimoli/cross.md +25 -0
  22. package/coms/zimoli/grid.js +1 -0
  23. package/coms/zimoli/inertia.md +13 -0
  24. package/coms/zimoli/lattice.md +5 -0
  25. package/coms/zimoli/list.js +1 -1
  26. package/coms/zimoli/list.md +10 -0
  27. package/coms/zimoli/maps.md +1 -0
  28. package/coms/zimoli/menuItem.html +10 -7
  29. package/coms/zimoli/menuItem.js +10 -5
  30. package/coms/zimoli/option.less +1 -1
  31. package/coms/zimoli/render.js +2 -2
  32. package/coms/zimoli/table.html +13 -7
  33. package/coms/zimoli/table.js +75 -22
  34. package/coms/zimoli/table.less +8 -1
  35. package/coms/zimoli/titlebar.js +1 -1
  36. package/coms/zimoli/vbox.js +2 -2
  37. package/coms/zimoli/zimoli.md +7 -0
  38. package/docs/index.html +9 -0
  39. package/docs/main.xht +8 -3
  40. package/docs//345/267/245/345/205/267//345/255/227/347/254/246/351/233/206/346/243/200/346/237/245.xht +157 -0
  41. package/package.json +1 -1
  42. package/public/efront.js +1 -1
  43. package/coms/zimoli/label.js +0 -4
@@ -23,6 +23,7 @@ var {
23
23
  console,
24
24
  efrontURI,
25
25
  parseFloat,
26
+ encodeURI,
26
27
  preventFrame,
27
28
  PREVENT_FRAMEWORK_MODE = preventFrame,
28
29
  devicePixelRatio = 1,
@@ -46,6 +47,7 @@ var efront_time = +new Date;
46
47
  var _devicePixelRatio = devicePixelRatio;
47
48
  var request = window.request || function (url, onload, onerror, version) {
48
49
  var xhr = new (XMLHttpRequest || ActiveXObject)("Microsoft.XMLHTTP");
50
+ url = encodeURI(url);
49
51
  xhr.open("POST", url);
50
52
  xhr.onreadystatechange = function () {
51
53
  if (xhr.readyState === 4) {
@@ -0,0 +1,7 @@
1
+ 图状数据序列化工具,与JSON语法一致
2
+ ```javascript
3
+ JSAM.stringify(obj);
4
+ JSAM.parse(str);
5
+ ```
6
+ 该工具已单独发布至[](https://www.npmjs.com/package/jsam),
7
+ 更多用法参考可参考该链接。
@@ -41,20 +41,25 @@ function inertia(gun) {
41
41
  var id = smooth_timer;
42
42
  var res = gun.apply(that, args);
43
43
  if (id !== smooth_timer) return;
44
+
44
45
  if (false === res) {
45
46
  spd.reset();
46
47
  train.state = 回弹;
47
48
  smooth_timer = requestAnimationFrame(_decrease);
48
49
  return;
49
50
  }
50
- if (decrease && args.filter(a => Math.abs(a) > 1).length === 0) {
51
+ if (args.stop || rate && args.rate < rate) {
52
+ if (!decrease) {
53
+ train.state = 停止;
54
+ return;
55
+ }
51
56
  train.state = 回弹;
52
57
  smooth_timer = requestAnimationFrame(_decrease);
53
58
  return;
54
59
  }
55
60
  smooth_timer = requestAnimationFrame(smooth);
56
61
  };
57
- var spd, smooth_timer, that, decrease;
62
+ var spd, smooth_timer, that, decrease, rate;
58
63
  var train = function () {
59
64
  _cancel();
60
65
  var args = [].slice.call(arguments, 0, arguments.length);
@@ -63,9 +68,10 @@ function inertia(gun) {
63
68
  gun.apply(this, args);
64
69
  that = this;
65
70
  };
66
- train.smooth = function (d) {
71
+ train.smooth = function (d, r) {
67
72
  _cancel();
68
73
  decrease = d;
74
+ rate = r;
69
75
  if (train.state === 移动) {
70
76
  train.state = 减速;
71
77
  smooth_timer = requestAnimationFrame(smooth);
@@ -162,16 +168,20 @@ class Speed extends Array {
162
168
  for (var v of values) sum += v * v;
163
169
  v = Math.sqrt(sum);
164
170
  var a = this.accelerate * Math.atan(v + 1);
171
+ values.rate = v;
165
172
  if (v > a + 1e-14) {
166
173
  v = Math.sqrt(v * (v - a)) / v;
167
174
  }
168
175
  else {
169
- v = 1e-9;
176
+ if (v < 1e-6) {
177
+ values.stop = true;
178
+ }
179
+ v = 0.6180339887498949;
170
180
  }
171
181
  var r = ratio * v;
172
182
  for (var cx = 0, dx = values.length; cx < dx; cx++) {
173
183
  values[cx] *= r;
174
- if (Math.abs(this[cx]) > .1) this[cx] *= v;
184
+ if (Math.abs(this[cx]) > 1e-16) this[cx] *= v;
175
185
  }
176
186
  return values;
177
187
  }
@@ -0,0 +1,58 @@
1
+ var test = function (queue, wait = 40) {
2
+ var spd = new Speed;
3
+ var now = 0;
4
+ var writted = [];
5
+ for (var cx = 0, dx = queue.length; cx < dx; cx++) {
6
+ var s = queue[cx];
7
+ if (s instanceof Array && !Array.isArray(queue[cx + 1])) {
8
+ spd.write(s, now = queue[++cx]);
9
+ writted.push(s, now);
10
+ }
11
+ else {
12
+ spd.write([].concat(s), now = cx * 16 + 20 + Math.random() * 16);
13
+ writted.push([].concat(s), now);
14
+ }
15
+ }
16
+ for (var cx = now + wait, dx = now + 20000; cx < dx; cx += 16 + Math.random() * 16) {
17
+ var a = spd.read(cx);
18
+ if (a.stop) break;
19
+ }
20
+ if (!a.stop) {
21
+ console.log("测试数据:", writted, "\r\n当前状态:", a);
22
+ throw `已等待 ${+((cx - now) / 1000).toFixed(3)} 秒,未停止运行`;
23
+ }
24
+ console.log(cx - now, a.stop);
25
+ };
26
+ Speed.debug = true;
27
+ test([
28
+ [2.1878654669544666],
29
+ 27.956586758709825,
30
+ [2.1878654669544666],
31
+ 37.21775999809554,
32
+ [3.1878654669544666],
33
+ 67.83162606867668
34
+ ])
35
+ test([1.1878654669544668, 1.1878654669544668, 1.1878654669544668]);
36
+ test([2.1878654669544668, 2.1878654669544668, 3.1878654669544668]);
37
+ test([
38
+ 0.3251661026176258,
39
+ 0.44988734829376603,
40
+ 0.43652435853899707,
41
+ 0.43652435853899707,
42
+ 0.47438616350792273,
43
+ 0.4253885330796093,
44
+ 0.5300652921323553,
45
+ 0.5256109608866051,
46
+ ]);
47
+ test([
48
+ [0, false], 2880.300000011921,
49
+ [0, false], 2894.300000011921,
50
+ [0, false], 2969,
51
+ [0, false], 2971.199999988079,
52
+ [0, false], 3019.600000023842,
53
+ [0, false], 3026.800000011921,
54
+ [0, false], 3044.5,
55
+ [0, false], 3114.900000035763,
56
+ [0, false], 3250.199999988079,
57
+ [0, false], 3314.699999988079
58
+ ], 900);
@@ -0,0 +1 @@
1
+ `YAML`格式解析工具,目前尚不完善,解析个别数据可能出错。
@@ -0,0 +1,10 @@
1
+ 依次传入数组中的数据,执行可能生成Promise的函数,类似如下代码:
2
+ ```javascript
3
+ for await(func());
4
+ 或:
5
+ for (){await func();}
6
+ ```
7
+ 用法如下:
8
+ ```javascript
9
+ queue.call(数组,func,最大并发数);
10
+ ```
@@ -0,0 +1,4 @@
1
+ 键值对序列化工具
2
+ ```javascript
3
+ serialize({ k1: v1, k2: v2 }, 分隔符, 等号);
4
+ ```
@@ -0,0 +1,4 @@
1
+ 文件名排序工具
2
+ ```javascript
3
+ sortname(文件名数组)
4
+ ```
@@ -0,0 +1,7 @@
1
+ 等待一个函数的返回值为真。用法如下:
2
+ ```javascript
3
+ wait(function(){
4
+ return ...;
5
+ }, 超时时长, 每次检查的时间间隔)
6
+ ```
7
+ 其中两个时间参数可不传入,超时时长默认为80毫秒,时间间隔按超时时长动态生成,约为其1/16。
@@ -90,6 +90,7 @@ Html.prototype.createScoped = function (code) {
90
90
  dom.childNodes = childNodes;
91
91
  dom.children = children;
92
92
  var scriptNodes = [], styleNodes = [], tempNodes = [];
93
+ var inScript = false;
93
94
  for (var cx = 0, dx = code.length, c = code[0]; cx < dx; c = code[++cx])switch (c.type) {
94
95
  case LABEL:
95
96
  if (!/^(script|style|template)$/i.test(c.text)) {
@@ -100,6 +101,7 @@ Html.prototype.createScoped = function (code) {
100
101
  if (!c.isclose) {
101
102
  var node = new Node;
102
103
  node.tagName = c.text.toUpperCase();
104
+ if (node.tagName === 'SCRIPT' || node.tagName === 'STYLE') inScript = true;
103
105
  nodePath.push(node);
104
106
  node.childNodes = [];
105
107
  node.children = [];
@@ -132,8 +134,8 @@ Html.prototype.createScoped = function (code) {
132
134
  }
133
135
  if (childNodes1.length) node.innerStart = childNodes1[0].outerStart;
134
136
  else node.innerStart = innerEnd;
135
- if (node.tagName === "SCRIPT") scriptNodes.push(node), tempNodes.push(node), node.isScript = true;
136
- else if (node.tagName === "STYLE") styleNodes.push(node), tempNodes.push(node), node.isStyle = true;
137
+ if (node.tagName === "SCRIPT") scriptNodes.push(node), tempNodes.push(node), node.isScript = true, inScript = false;
138
+ else if (node.tagName === "STYLE") styleNodes.push(node), tempNodes.push(node), node.isStyle = true, inScript = false;
137
139
  nodePath.pop();
138
140
  node = nodePath[nodePath.length - 1];
139
141
  childNodes = node.childNodes;
@@ -169,6 +171,7 @@ Html.prototype.createScoped = function (code) {
169
171
  }
170
172
  break;
171
173
  case EXPRESS:
174
+ if (inScript) continue;
172
175
  var t = c.text;
173
176
  t = parseExpress(t);
174
177
  var envs = createScoped(t).envs;
@@ -243,7 +246,7 @@ Html.prototype.createString = function (code) {
243
246
  for (var c of code) {
244
247
  switch (c.type) {
245
248
  case PIECE:
246
- if (p && p.type === PIECE) dist.push(" ");
249
+ if (p && p.type & (PIECE | EXPRESS)) dist.push(" ");
247
250
  dist.push(c.text);
248
251
  break;
249
252
  case SPACE:
@@ -549,6 +549,9 @@ class Program {
549
549
  var scope = [];
550
550
  scope.entry = m;
551
551
  scope.type = SCOPED;
552
+ scope.start = match.index;
553
+ scope.col = match.index - colstart;
554
+ scope.row = row;
552
555
  var last = queue.last;
553
556
  if (m === "{") {
554
557
  if (!last) {
@@ -579,7 +582,6 @@ class Program {
579
582
  scope.isExpress = queue.inExpress;
580
583
  scope.inExpress = true;
581
584
  }
582
- scope.start = match.index;
583
585
  push_parents(scope);
584
586
  continue;
585
587
  }
@@ -596,13 +598,13 @@ class Program {
596
598
  pop_parents();
597
599
  continue;
598
600
  }
599
-
601
+ if (this.scope_leave[m]) console.warn("标记不匹配", queue.entry, m, "queue:", `${queue.row}:${queue.col}`, "position:", `${row}:${index - colstart}\r\n`, text.slice(queue.start, index));
600
602
  if (this.stamp_reg.test(m)) {
601
603
  save(STAMP);
602
604
  }
603
605
 
604
606
  }
605
- if (queue !== origin) throw console.log(createString(origin), createString([queue])), new Error("代码异常结束");
607
+ if (queue !== origin) throw console.log(createString(origin), `\r\n------ deep: ${parents.length} - enrty: ${queue.entry} - length: ${queue.length} - last: ${createString([queue.last])} -----\r\n`, createString([queue])), "代码异常结束";
606
608
  return queue;
607
609
  }
608
610
  commit() {
@@ -619,11 +621,13 @@ class Program {
619
621
  quoteslike.forEach(q => {
620
622
  var a = q[0];
621
623
  if (a instanceof RegExp) a = stringsFromRegExp(a);
622
- if (typeof a === "string" && a.length === 1) tokens[a] = true;
623
624
  if (a instanceof Array) {
624
- a.forEach(a => quote_map[a] = q);
625
+ a.forEach(a => {
626
+ quote_map[a] = q;
627
+ tokens[a.charAt(0)] = true;
628
+ });
625
629
  }
626
- else quote_map[a] = q;
630
+ else quote_map[a] = q, tokens[a.charAt(0)] = true;
627
631
  var r = q.slice(q[2] ? 2 : 3).concat(q[1]).map(q => {
628
632
  if (q instanceof Array) {
629
633
  q = q[q.length - 2];
@@ -76,7 +76,7 @@ source += source.toUpperCase() + "_$";
76
76
  var number = source + '0123456789';
77
77
  // source += "ªµºΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψω";
78
78
  source += function () {
79
- var reg = /\xAA\xB5\xBA\xC0-\xD5\xD8-\xF2\xF8-\u02af\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA/;
79
+ var reg = /\xAA\xB5\xBA\xC0-\xD5\xD8-\xF2\xF8-\u02AF\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0523\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0621-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA/;
80
80
  var dist = [];
81
81
  reg.source.replace(/\\[xu]([0-9a-f]+)(?:\-\\[xu]([0-9a-f]+))?/ig, function (_, a, b) {
82
82
  a = parseInt(a, 16);
@@ -41,7 +41,7 @@ Richcss.prototype.setType = function (o) {
41
41
  };
42
42
  Richcss.prototype.createScoped = function (code) {
43
43
  var run = function (o) {
44
- var props = Object.create(null);
44
+ var props = [];
45
45
  var values = null;
46
46
  loop: while (o) {
47
47
  switch (o.type) {
@@ -51,7 +51,10 @@ Richcss.prototype.createScoped = function (code) {
51
51
  p.push(o.text);
52
52
  o = o.next;
53
53
  }
54
- props[p.join(" ")] = values = [];
54
+ var pj = p.join(' ');
55
+ props.push({ p: pj, v: values = [] });
56
+ if (!props[pj]) props[pj] = [];
57
+ props[pj].push(values);
55
58
  if (!o) break loop;
56
59
  if (o.type === STAMP) break;
57
60
  continue;
@@ -65,15 +68,14 @@ Richcss.prototype.createScoped = function (code) {
65
68
  case SCOPED:
66
69
  var s = run(o.first);
67
70
  var vars = null, used = null;
68
- for (var k in s) {
69
- var v = s[k];
71
+ for (var { p: k, v } of s) {
70
72
  if (/^\-\-/.test(k)) {
71
73
  if (!vars) vars = {};
72
74
  vars[k] = v.join(" ");
73
75
  }
74
76
  else {
75
77
  if (!used) used = [];
76
- used[k] = v;
78
+ used.push({ p: k, v });
77
79
  }
78
80
  }
79
81
  values.used = used;
@@ -113,11 +115,13 @@ var fixBase = function (b, a) {
113
115
  function evalscoped(scoped, scopeNames, base = '') {
114
116
  var root = scoped[":root"], scope = scoped[":scope"];
115
117
  var vars = Object.create(null);
116
- if (root) extend(vars, root.vars);
117
- if (scope) extend(vars, scope.vars);
118
+ if (root) root.forEach(r => extend(vars, r.vars));
119
+ if (scope) scope.forEach(s => extend(vars, s.vars));
118
120
  scopeNames.forEach(s => {
119
121
  var ss = scoped[s];
120
- if (ss) extend(vars, ss.vars), ss.rooted = true;
122
+ if (ss) ss.forEach(s => {
123
+ extend(vars, s.vars), s.rooted = true;
124
+ })
121
125
  });
122
126
  var vlist = [vars];
123
127
  var mlist = [];
@@ -154,8 +158,7 @@ function evalscoped(scoped, scopeNames, base = '') {
154
158
  return q + getFromScopeList(b || a.trim(), vlist, m.slice(q.length));
155
159
  });
156
160
  };
157
- for (var k in props) {
158
- var p = props[k];
161
+ for (var { p: k, v: p } of props) {
159
162
  if (p.used) {
160
163
  var match = /^(@[^\s,]+)\s*\(\s*(@[^\s,]+\s*(?:,\s*@[^\s,]+\s*)*)?\)/.exec(k);
161
164
  if (!match) continue;
@@ -164,7 +167,8 @@ function evalscoped(scoped, scopeNames, base = '') {
164
167
  args = args.split(",").map(a => a.trim());
165
168
  p.args = args;
166
169
  p.reg = new RegExp(args.join("|"), 'g');
167
- methods[name] = function () {
170
+ if (!methods[name]) methods[name] = [];
171
+ methods[name].push(function () {
168
172
  var body = evalthis(this);
169
173
  var valueMap = {};
170
174
  this.args.forEach((a, i) => {
@@ -178,12 +182,12 @@ function evalscoped(scoped, scopeNames, base = '') {
178
182
  var body = body.map(replace);
179
183
  body.rest = rest;
180
184
  return body;
181
- }.bind(p);
182
- delete props[k];
185
+ }.bind(p));
186
+ p.isMethod = true;
183
187
  }
184
188
  }
185
- for (var k in props) {
186
- var p = props[k];
189
+ for (var { p: k, v: p } of props) {
190
+ if (p.isMethod) continue;
187
191
  if (p.used) {
188
192
  if (base && !p.rooted) p.base = fixBase(base, k);
189
193
  else p.base = k;
@@ -201,10 +205,12 @@ function evalscoped(scoped, scopeNames, base = '') {
201
205
  var [, name, params] = match;
202
206
  params = params.split(",").map(a => a.trim());
203
207
  var method = getFromScopeList(name, mlist);
204
- if (!isFunction(method)) throw `函数未定义:${name}`;
205
- var res = method.apply(null, params);
206
- if (res.rest.length) rest = rest.concat(res.rest);
207
- if (res.length) result = result.concat(res);
208
+ if (!isArray(method)) throw `函数未定义:${name}`;
209
+ method.forEach(m => {
210
+ var res = m.apply(null, params);
211
+ if (res.rest.length) rest = rest.concat(res.rest);
212
+ if (res.length) result = result.concat(res);
213
+ });
208
214
  }
209
215
  }
210
216
  mlist.pop();
@@ -96,15 +96,21 @@ function testJsxOnlyHtml() {
96
96
  <component1 ng-bind="expression"><child1></child1></component1>`);
97
97
  console.log(m.toString());
98
98
  }
99
+ function testSpaceLess() {
100
+ var m = scanner(`if(n<0)return'_f("'+t+'")('+e+")"`);
101
+ console.log(m.toString());
102
+ }
103
+ Program.debug = true;
99
104
  // testSpeed();
100
105
  // testVariables();
101
106
  // testRegexp();
102
107
  // testStatic();
103
108
  // testAssign();
104
109
  // testFormat();
105
- testJsx();
106
- testJsx2();
110
+ // testJsx();
111
+ // testJsx2();
107
112
  // testJsx3();
108
- testJsxOnlyHtml();
113
+ // testJsxOnlyHtml();
114
+ testSpaceLess();
109
115
  // var typescript = require("../typescript/index");
110
116
  // typescript.transpile(data.toString(), { noEmitHelpers: true });
@@ -70,8 +70,8 @@ function richtext(line) {
70
70
  line = line.trim();
71
71
  line = line.replace(/\[([\s\S]*?)\](?:\(([\s\S]*?)\))?|<(\w+)>[\s\S]*?<\/\3>/g, function (_, content, href) {
72
72
  if (/^\</.test(_)) return _;
73
- if (href) href = ` href=${strings.recode(href)}`;
74
- return `<a${href}>${content}</a>`;
73
+ if (href) var href1 = ` href=${strings.recode(href)}`;
74
+ return `<a${href1}>${content || href}</a>`;
75
75
  });
76
76
  var a;
77
77
  if (/^#/.test(line)) a = h(line);
@@ -34,7 +34,7 @@ var colorReg = /<(\/?)([a-z][\w]*)\>/ig;
34
34
  var renderColor = function (obj) {
35
35
  var colorpath = [];
36
36
  return String(obj).replace(colorReg, function (_, e, c) {
37
- if (!getColor(c)) return _;
37
+ if (!c || c.length < 3 || !getColor(c)) return _;
38
38
  if (e) {
39
39
  colorpath.pop();
40
40
  c = colorpath[colorpath.length - 1];
@@ -0,0 +1,12 @@
1
+ 替换已知函数中的方向属性(left,top,width,height,x,y等),生成转置函数。
2
+ 如:
3
+ ```javascript
4
+ var 水平方向操作 = function(elem,event){
5
+ var top = event.clientY - elem.offsetTop;
6
+ };
7
+ var 垂直方向操作 = function(elem,event){
8
+ var left = event.clientX - elem.offsetLeft;
9
+ };
10
+ 等同于:
11
+ var 垂直方向操作 = arriswise(水平方向操作,arguments);
12
+ ```
@@ -70,6 +70,7 @@ var scrollX = function (targetBox, moveChildren) {
70
70
  scrollDelta = dragPosition.right + 20 - areaPosition.right;
71
71
  }
72
72
  if (scrollDelta) {
73
+ if (targetBox === document.documentElement) return;
73
74
  vscroll.X.call(targetBox, scrollDelta / 16, false);
74
75
  moveChildren();
75
76
  }
@@ -0,0 +1,12 @@
1
+ 子项拖拽工具,两种用法可配合使用
2
+ ```javascript
3
+ // 启用元素内的拖拽排序
4
+ autodragchildren(元素, 子项过滤器, function(fromIndex,toIndex){
5
+ // 此回调函数可用于处理数据,也可以什么都不做
6
+ // 如果返回false 元素位置将不被调换
7
+ });
8
+ // 对已捕获的事件启用拖拽
9
+ autodragchildren.hook(event, target/*用于向用户展示拖拽效果的元素*/,function (接收拖拽的元素/*此元素应具有 allowdrop 属性*/) {
10
+ });
11
+ ```
12
+ 更具体的用法可参考代码 [](https://github.com/yunxu1019/qfy/blob/master/page/home/edit.js)
@@ -20,7 +20,7 @@ function main(elem = document.createElement("checkbox-group")) {
20
20
  options,
21
21
  select(a) {
22
22
  a.checked = !a.checked;
23
- elem.value = this.options.filter(a => !!a.checked);
23
+ elem.checked = elem.value = this.options.filter(a => !!a.checked);
24
24
  buildValue(elem.value, this.options);
25
25
  dispatch(elem, 'change');
26
26
  }
@@ -0,0 +1,25 @@
1
+ 网络请求工具
2
+ ```javascript
3
+ var xhr = await cross(请求方法,请求路径,头信息).send(数据);
4
+ console.log(xhr.response) // 已对不存在response属性的浏览器做兼容,可放心使用
5
+ ```
6
+ 默认会通过当前服务器转发请求,请求结果会附加跨域头信息,可以通过`cross.addDirect`指定免转发的服务器
7
+ 如:
8
+ ```javascript
9
+ cross.addDirect('efront.cc');
10
+ 或:
11
+ cross.addDirect(/efront\.cc$/);
12
+ ```
13
+ 对于无服务器项目或不使用efront做为服务器的项目,也可以通过`cross.setHost`指定用以转发的服务器,如:
14
+ ```javascript
15
+ cross.setHost('efront.cc');
16
+ ```
17
+ 可以用efront的编译开关区分生成环境和测试环境,如:
18
+ ```javascript
19
+ cross.setHost('efront.cc');
20
+ // <!--
21
+ // 这里的代码会在live命令中生效
22
+ // 会在build命令中移除
23
+ cross.setHost('localhost');
24
+ // -->
25
+ ```
@@ -308,6 +308,7 @@ function grid(breakpoints) {
308
308
  }
309
309
  class Point extends Array {
310
310
  constructor(value, range) {
311
+ super();
311
312
  var solid = false;
312
313
  if (isObject(value)) {
313
314
  this.value = value.value;
@@ -0,0 +1,13 @@
1
+ 非线性减速插值工具,可用于用户的滚动或拖动操作平滑停止
2
+ ```javascript
3
+ var f = inertia(function(a){
4
+ // 一个参数或多个参数,都应为有限的数值,未对其他情况进行测试或排错
5
+ console.log(a);
6
+ });
7
+ f(2);
8
+ await new Promise(ok=>setTimeout(ok,20));
9
+ f(2);
10
+ f.smooth(function(){
11
+ // 结束时的回调,可不传入
12
+ }, 最小可用速度/*高维空间中参数向量的模,可不传入*/);
13
+ ```
@@ -0,0 +1,5 @@
1
+ 网格排列工具,每行元素最好有一样的高度,超出宽度后自动换行,其行为类似windows操作系统的文件管理窗口
2
+ ```html
3
+ <!-- 用法与list组件一致,增加一个 item-width 属性,可不设置 -->
4
+ <lattice efront-src="item in items" item-width=280 ></lattice>
5
+ ```
@@ -390,7 +390,7 @@ function ylist(container, generator, $Y) {
390
390
  }
391
391
  if (absy <= 1) y = target_y;
392
392
  else {
393
- var speed = Math.abs(spd.read()[0]);
393
+ var speed = spd.read().rate;
394
394
  if (speed < 1) speed = 1;
395
395
  if (absy < 3) speed = .5;
396
396
  y = last_y + (target_y > last_y ? speed : -speed);
@@ -0,0 +1,10 @@
1
+ 列表工具,比ng-repeat或v-for的优势在于,它内置了大数据量的高效展示算法。
2
+ ```html
3
+ <!-- 语法与 ng-repeat 或 v-for 类似,前缀随意 -->
4
+ <list efront-src="item in items" >
5
+ <div>
6
+ <span -bind="item.name"></span>
7
+ <span -bind="item.silasiladi"></span>
8
+ </div>
9
+ </list>
10
+ ```
@@ -0,0 +1 @@
1
+ 一个地图展示的小工具,目前只有展示瓦片地图(OSM、百度、高德、谷歌等)的功能,无任何其他附加功能。如果您在开发地图类应用,建议使用`openlayers`等已基本成熟的地图框架,不要使用这个可能在未来大修大补的模块。
@@ -1,14 +1,17 @@
1
- <template -if='useIcon?||hasIcon?||icon?'>
2
- <i -class="icon?" -style="{color:color?}"></i>
3
- <template -if="name?">
1
+ <template -if='hasIcon?'>
2
+ <i -class="icon?" -style="{color:menu.color}"></i>
3
+ <template -if="menu.name">
4
4
  &nbsp;&nbsp;
5
5
  </template>
6
6
  </template>
7
- <span -html="name?" -style="{color:color?}"></span>
8
- <template -if="typeof hotkey==='string'">
7
+ <span -html="menu.name" -style="{color:menu.color}"></span>
8
+ <template -if="typeof menu.hotkey==='string'">
9
9
  &nbsp;&nbsp; <span class="hotkey" -html="hotkey"></span>
10
10
  </template>
11
- <template -elseif="hotkey?.length">
12
- &nbsp;&nbsp; <span ng-repeat="k of hotkey" class="hotkey" ng-html="k"></span>
11
+ <template -elseif="menu.hotkey?.length">
12
+ &nbsp;&nbsp; <span ng-repeat="k of menu.hotkey" class="hotkey" ng-html="k"></span>
13
+ </template>
14
+ <template -if="menu.isChecked?menu.isChecked():''">
15
+ &nbsp;&nbsp;✓
13
16
  </template>
14
17
  <s></s>
@@ -7,16 +7,21 @@ function main(elem, scope, hasIcon) {
7
7
  else if (item.$scope) {
8
8
  var scope = item.$scope;
9
9
  }
10
- if (scope.menu || scope.$item) scope = scope.menu || scope.$item;
11
- if (hasIcon === undefined) hasIcon = !!scope.icon;
12
- if (scope.disabled || scope.enabled === false) {
10
+ var menu = scope;
11
+ if (menu.menu || menu.$item) menu = menu.menu || menu.$item;
12
+ if (menu.disabled || menu.enabled === false) {
13
13
  item.setAttribute('disabled', '');
14
14
  }
15
15
  else {
16
16
  item.removeAttribute("disabled");
17
17
  }
18
- render(item.children, scope, hasIcon instanceof Array ? hasIcon : [{ useIcon: hasIcon, hasIcon }]);
19
- if (scope.line) item.setAttribute("line", ''), on("click")(item, preventDefault);
18
+ scope = {
19
+ menu,
20
+ checker,
21
+ };
22
+ if (hasIcon) scope.hasIcon = true;
23
+ render(item.children, scope);
24
+ if (menu.line) item.setAttribute("line", ''), on("click")(item, preventDefault);
20
25
  return item;
21
26
  }
22
27
  main.template = menuItem;
@@ -4,7 +4,7 @@
4
4
  top: 0;
5
5
  left: 0;
6
6
  bottom: 0;
7
- padding: 0 !important;
7
+ padding: 0;
8
8
  color: #333;
9
9
  right: 0;
10
10
  display: block;