efront 3.25.3 → 3.25.8

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 (49) hide show
  1. package/apps/_index.html +1 -1
  2. package/apps/pivot/log/count.html +2 -2
  3. package/coms/basic/Field.js +5 -0
  4. package/coms/basic/Item.js +16 -6
  5. package/coms/basic/Speed.js +20 -6
  6. package/coms/basic/Table.js +120 -0
  7. package/coms/basic/Tree.js +4 -4
  8. package/coms/basic/loader.js +11 -8
  9. package/coms/basic/mark.js +7 -5
  10. package/coms/basic/parseKV.js +1 -1
  11. package/coms/basic/with_.js +6 -0
  12. package/coms/basic/withget_.js +6 -0
  13. package/coms/frame/route.js +7 -1
  14. package/coms/kugou/playList.less +6 -0
  15. package/coms/random//350/272/253/344/273/275/350/257/201.js +4 -3
  16. package/coms/zimoli/alert.js +12 -13
  17. package/coms/zimoli/autodragchildren.js +4 -1
  18. package/coms/zimoli/cloneVisible.js +8 -2
  19. package/coms/zimoli/color.js +9 -4
  20. package/coms/zimoli/contextmenu.js +1 -1
  21. package/coms/zimoli/drag.js +1 -1
  22. package/coms/zimoli/getName.js +14 -6
  23. package/coms/zimoli/hexagon.js +33 -0
  24. package/coms/zimoli/list.js +5 -5
  25. package/coms/zimoli/menuItem.html +5 -2
  26. package/coms/zimoli/menuItem.less +1 -1
  27. package/coms/zimoli/menuList.js +30 -15
  28. package/coms/zimoli/menuList.less +0 -1
  29. package/coms/zimoli/moveupon.js +1 -0
  30. package/coms/zimoli/picture_.js +10 -10
  31. package/coms/zimoli/popup.js +4 -2
  32. package/coms/zimoli/render.js +1 -1
  33. package/coms/zimoli/resize.js +1 -0
  34. package/coms/zimoli/search.js +3 -72
  35. package/coms/zimoli/selectList.js +2 -1
  36. package/coms/zimoli/slider.js +21 -9
  37. package/coms/zimoli/table.js +18 -12
  38. package/coms/zimoli/table.less +9 -0
  39. package/coms/zimoli/touchList.js +22 -20
  40. package/coms/zimoli/tree.js +3 -2
  41. package/coms/zimoli/tree.less +4 -4
  42. package/coms/zimoli/vbox.js +6 -5
  43. package/coms/zimoli/watch.js +26 -0
  44. package/docs/compare.md +16 -10
  45. package/docs/main.js +3 -3
  46. package/package.json +5 -9
  47. package/public/efront.js +1 -1
  48. package/coms/zimoli/$objectHash.js +0 -22
  49. package/coms/zimoli/$objectHash_test.js +0 -15
package/apps/_index.html CHANGED
@@ -9,7 +9,7 @@
9
9
  <meta charset="utf-8" />
10
10
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
11
11
  <link rel="Shortcut Icon" href="/favicon.ico" type="image/x-icon" />
12
- <meta name="viewport" content="initial-scale=1,maximum-scale=1,width=device-width" />
12
+ <meta name="viewport" content="initial-scale=1,maximum-scale=1,width=device-width,user-scalable=no,initial-scale=1" />
13
13
  <title>efront 项目</title>
14
14
  <script deleteoncompile efrontloader>
15
15
  // 若要在开发环境使用内置组件,请保留此script标签中的代码,在编译发布时,这里的代码会自动删除
@@ -1,5 +1,5 @@
1
1
  <div class="searchbox">
2
- <input @input="filter" -model="searchText" />
2
+ <input -model="searchText" />
3
3
  </div>
4
- <table -src="[fields,items]">
4
+ <table -src="[fields,items]" _find="searchText">
5
5
  </talbe>
@@ -0,0 +1,5 @@
1
+ class Field {
2
+ key = '';
3
+ name = '';
4
+ sort = 0;
5
+ }
@@ -1,5 +1,6 @@
1
1
  var id = 0;
2
2
  class Item extends Array {
3
+ extended = false;
3
4
  constructor(value) {
4
5
  super();
5
6
  this.children = this;
@@ -7,10 +8,11 @@ class Item extends Array {
7
8
  this.total = 0;//子项中的节点数
8
9
  this.crack = 0;
9
10
  this.id = ++id;
10
- this.extends(value);
11
+ this.extends(value, false);
11
12
  }
12
- extends(value) {
13
- if (value instanceof Item) this.value = value.value;
13
+ extends(value, mark) {
14
+ this.extended = mark !== false;
15
+ if (value && value.constructor === Item) this.value = value.value;
14
16
  else this.value = value;
15
17
  if (value.children instanceof Array) {
16
18
  var children = value.children.map(item => new Item(item));
@@ -33,12 +35,20 @@ class Item extends Array {
33
35
  this.tab = 1;
34
36
  }
35
37
  }
38
+ get disabled() {
39
+ if (isObject(this.value)) return this.value.disabled || this.value.enabled === false;
40
+
41
+ return false;
42
+ }
43
+ get hotkey() {
44
+ if (isObject(this.value)) return this.value.hotkey;
45
+ }
36
46
 
37
47
  valueOf() {
38
48
  return this.value;
39
49
  }
40
50
  toString() {
41
- return String(this.value);
51
+ return String(this.name);
42
52
  }
43
53
  get warn() {
44
54
  if (isObject(this.value)) {
@@ -47,8 +57,8 @@ class Item extends Array {
47
57
  return false;
48
58
  }
49
59
  get name() {
50
- if (isObject(this.value)) return this.value.name;
51
- return this.value;
60
+ if (isObject(this.value)) return getName(this.value);
61
+ return String(this.value);
52
62
  }
53
63
 
54
64
  isClosed() {
@@ -1,18 +1,25 @@
1
1
  function inertia(gun) {
2
2
  var _decreased = 0, spd = new Speed;
3
+ var lastTime = 0;
3
4
  var _decrease = function () {
5
+ lastTime = Speed.now() - 1;
6
+ _decrease0();
7
+ }
8
+ var _decrease0 = function () {
4
9
  if (
5
10
  decrease instanceof Function
6
11
  ) {
7
12
  if (!spd.length || _decreased > 0 && spd.filter(a => a !== 0).length === 0) return;
8
13
  var id = smooth_timer;
9
- var res = decrease(_decreased++, spd);
14
+ var now = Speed.now();
15
+ var res = decrease(now - lastTime, spd);
16
+ lastTime = now;
10
17
  if (smooth_timer !== id) return;
11
18
  if (res === false || isEmpty(res)) {
12
19
  spd.unset();
13
20
  return;
14
21
  }
15
- smooth_timer = requestAnimationFrame(_decrease);
22
+ smooth_timer = requestAnimationFrame(_decrease0);
16
23
  }
17
24
  };
18
25
  var _cancel = function () {
@@ -26,7 +33,7 @@ function inertia(gun) {
26
33
  _decrease();
27
34
  return;
28
35
  }
29
- if (args.filter(a => Math.abs(a) > .5).length === 0) {
36
+ if (!decrease && args.filter(a => Math.abs(a) > .5).length === 0) {
30
37
  spd.reset();
31
38
  return;
32
39
  }
@@ -63,6 +70,7 @@ function inertia(gun) {
63
70
  class Speed extends Array {
64
71
  cache = [];
65
72
  stamp = 0;
73
+ deltat = 0;
66
74
  static now() {
67
75
  return performance.now ? performance.now() : Date.now();
68
76
  }
@@ -103,20 +111,26 @@ class Speed extends Array {
103
111
  if (this.stamp) ratio = now - this.stamp;
104
112
  else ratio = deltat;
105
113
  if (ratio > 160) ratio = 1e-3;
114
+ if (this.deltat) {
115
+ if (deltat > this.deltat * 10) {
116
+ ratio = 1e-3;
117
+ }
118
+ }
119
+ this.deltat = deltat;
106
120
  this.stamp = now;
107
121
  var sum = 0;
108
122
  for (var v of values) sum += v * v;
109
123
  v = Math.sqrt(sum) * ratio;
110
124
  if (v > 1) {
111
- v = Math.sqrt(v * (v - 1)) / v;
125
+ v = Math.sqrt(v * (v - .996)) / v;
112
126
  }
113
127
  else {
114
- v = 1e-7;
128
+ v = .9;
115
129
  }
116
130
  var r = ratio * v;
117
131
  for (var cx = 0, dx = values.length; cx < dx; cx++) {
118
132
  values[cx] *= r;
119
- this[cx] *= v;
133
+ if (Math.abs(this[cx]) > .1) this[cx] *= v;
120
134
  }
121
135
  return values;
122
136
  }
@@ -0,0 +1,120 @@
1
+
2
+ function minusPower(a, b) {
3
+ return a.power - b.power >= 0;
4
+ }
5
+ function returnName() {
6
+ return this.name;
7
+ }
8
+ function searchThis(field) {
9
+ return /^$|text|input|html/i.test(field.type);
10
+ }
11
+ class Table extends Array {
12
+ searchText = null;
13
+ sortFields = [];
14
+ searchFields = null;
15
+ fields = [];
16
+ sorted = null;
17
+ source = null;
18
+ complete = true;
19
+ searched = 0;
20
+ searchid = 0;
21
+ coverCount = 0;
22
+ hasFullmatch = false;
23
+ callback = null;
24
+ static from(fields, data) {
25
+ var t = new Table;
26
+ t.fields = fields;
27
+ t.source = data;
28
+ t.searchFields = fields.filter(searchThis);
29
+ t.update();
30
+ return t;
31
+ }
32
+ /**
33
+ * @param {Field} field
34
+ */
35
+ sort(field) {
36
+ removeFromList(this.sortFields, field);
37
+ this.sortFields.push(field);
38
+ var sorted = this.sorted || this.source.slice(0);
39
+ field.sort = field.sort > 0 ? -1 : 1;
40
+ this.sorted = sorted.sort(function (a, b) {
41
+ a = seek(a, field.key);
42
+ b = seek(b, field.key);
43
+ if (a > b) return field.sort;
44
+ if (a < b) return -field.sort;
45
+ return 0;
46
+ });
47
+ this.update();
48
+ }
49
+ unsort() {
50
+ this.sorted = null;
51
+ this.update();
52
+ }
53
+ addItem(o) {
54
+ if (isEmpty(o)) return;
55
+ var searchtext = this.searchText;
56
+ var fields = this.searchFields ? this.searchFields : this.fields;
57
+ var power = 0;
58
+ if (isNode(o)) {
59
+ o = extend({
60
+ name: o.name,
61
+ title: o.title,
62
+ value: o.value,
63
+ key: o.key,
64
+ nodeType: o.nodeType,
65
+ tagName: o.tagName,
66
+ nodeValue: o.nodeValue,
67
+ }, o);
68
+ }
69
+ else o = isObject(o) ? Object.create(o) : new o.constructor(o);
70
+ for (var f of fields) {
71
+ var name = seek(o, f.key);
72
+ if (isEmpty(name) || !isString(name)) continue;
73
+ if (name === searchtext) this.hasFullmatch = true;
74
+ var [p, m] = mark.power(name, searchtext);
75
+ power += p;
76
+ if (p >= searchtext.length) this.coverCount++;
77
+ if (isString(f.key)) o[f.key] = m;
78
+ else o.name = m, o.toString = returnName, o.valueOf = returnName;
79
+ }
80
+ o.power = power;
81
+ if (o.power > 0) {
82
+ saveToOrderedArray(this, o, minusPower);
83
+ }
84
+ }
85
+ search(text, callback) {
86
+ if (isFunction(callback)) this.callback = callback;
87
+ if (text === this.searchText) return;
88
+ this.searchText = text;
89
+ this.update();
90
+ }
91
+ async update() {
92
+ this.searched = 0;
93
+ this.splice(0, this.length);
94
+ var source = this.sorted ? this.sorted : this.source;
95
+ var searchid = ++this.searchid;
96
+ this.complete = false;
97
+ this.coverCount = 0;
98
+ if (this.searchText) for (var o of source) {
99
+ this.addItem(o);
100
+ if (++this.searched % 600 === 0) {
101
+ if (isFunction(this.callback)) this.callback();
102
+ await new Promise(function (ok) {
103
+ requestAnimationFrame(ok)
104
+ });
105
+ if (this.searchid !== searchid) break;
106
+ }
107
+ }
108
+ else {
109
+ while (this.searched < source.length) {
110
+ this.push.apply(this, source.slice(this.searched, this.searched += 6000));
111
+ }
112
+ this.searched = source.length;
113
+ }
114
+ this.complete = true;
115
+ if (isFunction(this.callback)) this.callback();
116
+ }
117
+ abort() {
118
+ this.searchid++;
119
+ }
120
+ }
@@ -6,7 +6,7 @@ class Tree extends Array {
6
6
  count = 0;
7
7
  total = 0;
8
8
  constructor(src) {
9
- if (src instanceof Tree) return src;
9
+ if (src && src.coustructor === Tree) return src;
10
10
  if (src instanceof Array && src[0] && ('tab' in src[0] || 'deep' in src[0])) {
11
11
  return Tree.fromArray(src);
12
12
  }
@@ -20,7 +20,7 @@ class Tree extends Array {
20
20
  this.root = this;
21
21
  }
22
22
  static fromData(array) {
23
- if (array instanceof Tree) return array;
23
+ if (array && array.coustructor === Tree) return array;
24
24
  var root = new Tree;
25
25
  root.tab = -Infinity;
26
26
  root.count = 0;
@@ -82,7 +82,7 @@ class Tree extends Array {
82
82
  return root;
83
83
  }
84
84
  static fromArray(array) {
85
- if (array instanceof Tree) return array;
85
+ if (array && array.constructor === Tree) return array;
86
86
  var root = new Tree;
87
87
  root.tab = -Infinity;
88
88
  root.count = 0;
@@ -162,7 +162,7 @@ class Tree extends Array {
162
162
  var datas = [];
163
163
  for (var cx = 1, dx = arguments.length; cx < dx; cx++) {
164
164
  var arg = arguments[cx];
165
- if (arg instanceof Item) datas.push(arg);
165
+ if (arg && arg.constructor === Item) datas.push(arg);
166
166
  else if (arg instanceof Array) datas.push.apply(datas, arg);
167
167
  else datas.push(arg);
168
168
  }
@@ -40,6 +40,7 @@ if (PREVENT_FRAMEWORK_MODE !== false) {
40
40
  return;
41
41
  }
42
42
  }
43
+ var efront_time = +new Date;
43
44
  var _devicePixelRatio = devicePixelRatio;
44
45
  var request = window.request || function (url, onload, onerror, version) {
45
46
  var xhr = new (XMLHttpRequest || ActiveXObject)("Microsoft.XMLHTTP");
@@ -653,12 +654,7 @@ var removeGlobalProperty = function (property) {
653
654
  };
654
655
 
655
656
  var renderPixelRatio = !/win/i.test(navigator.platform) && devicePixelRatio > 1 && window.innerWidth > 360 && window.innerHeight > 360 ? .86 : .75;
656
- if (document.querySelector && devicePixelRatio > 1 && /Linux/.test(navigator.platform) && navigator.maxTouchPoints > 0) {
657
- let ratio = +(1000000 / devicePixelRatio + .5 | 0) / 1000000;
658
- document.querySelector("meta[name=viewport]").setAttribute("content", `width=device-width,target-densitydpi=device-dpi,user-scalable=no,initial-scale=1,maximum-scale=${ratio}`);
659
- renderPixelRatio *= devicePixelRatio;
660
- devicePixelRatio = 1;
661
- }
657
+
662
658
  var initPixelDecoder = function () {
663
659
  if (pixelDecoder instanceof Function) {
664
660
  modules.fromPixel = pixelDecoder;
@@ -832,8 +828,7 @@ var loadResponseTreeFromStorage = function () {
832
828
  };
833
829
  };
834
830
  var preLoad = function () { };
835
-
836
- var start_time = +new Date / 1000 | 0;
831
+ var start_time = efront_time / 1000 | 0;
837
832
  var errored = {};
838
833
  var modules = {
839
834
  isProduction,
@@ -868,6 +863,14 @@ var hook = function (requires_count) {
868
863
  modules.Promise = Promise;
869
864
  modules.hook_time = +new Date;
870
865
  if (!efrontPath) efrontPath = document.body.getAttribute("main-path") || document.body.getAttribute("path") || document.body.getAttribute("main") || "zimoli";
866
+ if (modules.hook_time - efront_time < (isProduction ? 30 : 5) && document.querySelector && devicePixelRatio > 1 && /Linux/.test(navigator.platform) && navigator.maxTouchPoints > 0) {
867
+ let ratio = +(1000000 / devicePixelRatio + .5 | 0) / 1000000;
868
+ document.querySelector("meta[name=viewport]").setAttribute("content", `width=device-width,target-densitydpi=device-dpi,user-scalable=no,initial-scale=1,maximum-scale=${ratio}`);
869
+ renderPixelRatio *= devicePixelRatio;
870
+ modules.renderPixelRatio = renderPixelRatio;
871
+ devicePixelRatio = modules.devicePixelRatio = 1;
872
+ }
873
+
871
874
  init(efrontPath, function (zimoli) {
872
875
  if (zimoli instanceof Function) zimoli();
873
876
  });
@@ -57,8 +57,8 @@ var power = function (source, search) {
57
57
  var match_start2 = matchers[1];
58
58
  if (search.length === 1) {
59
59
  var p = 0;
60
- var res = source.replace(new RegExp(search.replace(/[\\\*\?\+\(\)\[]/g, "\\$&"), "g"), () => {
61
- if (!p) p = 1;
60
+ var res = source.replace(new RegExp(search.replace(/[\\\*\?\+\(\)\[]/g, "\\$&"), "g"), (m, i) => {
61
+ if (!p) p = .1 / (1 + i);
62
62
  return MARK_PRE1 + search + MARK_AFT1;
63
63
  });
64
64
  return [p, res];
@@ -68,15 +68,17 @@ var power = function (source, search) {
68
68
  var match_text_aft = source.slice(match_start2 + match_text.length);
69
69
  var pp = 0, ap = 0;
70
70
  var p = match_text.length;
71
- if (match_text_pre.length) p += .1 / match_text_pre.length - .2;
72
- if (match_text_aft.length) p += .1 / match_text_aft.length - .1;
71
+ p = match_text.length;
72
+ if (match_start2) p += .1 / match_start2;
73
73
  if (match_text_pre.length > 1) {
74
74
  [pp, match_text_pre] = power(match_text_pre, search);
75
75
  }
76
76
  if (match_text_aft.length > 1) {
77
77
  [ap, match_text_aft] = power(match_text_aft, search);
78
78
  }
79
- p += (pp + ap) * .01;
79
+ if (match_text.length !== search.length) {
80
+ p += (pp + ap) / source.length / search.length * .01 - .2;
81
+ }
80
82
  return [p, match_text_pre.concat(MARK_PRE1, match_text, MARK_AFT1, match_text_aft)];
81
83
  }
82
84
  return [0, source];
@@ -25,7 +25,7 @@ function parseKV(string) {
25
25
  if (index < 0) index = kv.length;
26
26
  var k = kv.slice(0, index);
27
27
  var v = kv.slice(index + 1);
28
- if (isFunction(decode)) {
28
+ if (typeof decode === 'function') {
29
29
  k = decode(k);
30
30
  v = decode(v);
31
31
  }
@@ -0,0 +1,6 @@
1
+ function with_(k, objlist) {
2
+ for (var o of objlist) {
3
+ if (k in o) return o;
4
+ }
5
+ return;
6
+ }
@@ -0,0 +1,6 @@
1
+ function withget_(k, objlist, v) {
2
+ for (var o of objlist) {
3
+ if (k in o) return o[k];
4
+ }
5
+ return v;
6
+ }
@@ -108,6 +108,8 @@
108
108
  if (path) item.path = path;
109
109
  if (data) item.params = parseKV(data);
110
110
  item.closed = true;
111
+ if (filter) var item0 = filter(item);
112
+ if (item0) item = item0;
111
113
  return item;
112
114
  });
113
115
  return items;
@@ -231,10 +233,14 @@
231
233
  result.then = then;
232
234
  return result;
233
235
  };
234
- result.parse = function (items) {
236
+ var filter = null;
237
+ result.parse = function (items, f) {
238
+ filter = f;
235
239
  keymap = {};
236
240
  items = parseMenuList(items);
237
241
  items.keymap = keymap;
242
+ filter = null;
243
+ keymap = null;
238
244
  return items;
239
245
  };
240
246
  var then = function (ok, oh) {
@@ -13,6 +13,12 @@
13
13
  transition: margin .2s ease-out;
14
14
  }
15
15
 
16
+ >list.body {
17
+ overflow-x: hidden;
18
+ overflow-y: scroll;
19
+ padding: 0;
20
+ }
21
+
16
22
 
17
23
  list>padding {
18
24
  display: block;
@@ -96,7 +96,8 @@ var parse = function (r) {
96
96
  case 18:
97
97
  s = r.slice(17, 18);
98
98
  case 17:
99
- o = r.slice(14, 17);
99
+ o = r.slice(14, 17) >> 1;
100
+ x = r.slice(16, 17) & 1;
100
101
  case 14:
101
102
  d = r.slice(12, 14);
102
103
  case 12:
@@ -117,7 +118,7 @@ var parse = function (r) {
117
118
  case 3:
118
119
  o = r >> 1;
119
120
  case 1:
120
- x = o & 1;
121
+ x = r & 1;
121
122
  break;
122
123
  case 2:
123
124
  m = r;
@@ -135,7 +136,7 @@ function 身份证(r) {
135
136
  var q = r0 * 20220309 | 0;
136
137
  var d = birth(q);
137
138
  var [p = code(q), y = d.getFullYear(), m = d.getMonth() + 1, d = d.getDate(), o = order(r0), x = sex(r0)] = parse(r);
138
- middle = (y * 10000 + m * 100 + d) * 1000 + (o << 1 | x);
139
+ middle = (y * 10000 + m * 100 + +d) * 1000 + (o << 1 | x);
139
140
  p17 = p + middle;
140
141
  }
141
142
  if (!p17) {
@@ -8,7 +8,7 @@ styles.success = styles.pass = styles.green;
8
8
  styles.info = styles.blue;
9
9
  styles.error = styles.danger = styles.red;
10
10
  styles.warn = styles.orange;
11
- styles.default = '#000';
11
+ styles.default = '#000a';
12
12
  var alerts = [];
13
13
  var clean = Cleanup(alerts);
14
14
  var build = function () {
@@ -24,14 +24,13 @@ var fontSize = 16;
24
24
  var singleHeight = fontSize * 3.125 | 0;
25
25
  var _text = function (bgcolor, parameters) {
26
26
  var box = div();
27
- css(box, `top:${fromPixel(alerts.length ? Math.max.apply(Math, alerts.map(e => e.offsetTop + e.children[0].offsetHeight)) : 0)};height:0;line-height:${fromPixel(singleHeight - 20)};left:0;right:0;font-size:${fromPixel(fontSize)}; transition: all 0.2s ease-out;position:absolute;color:#fff;text-align:center;`);
28
- box.innerHTML = `<div style='width: 720px;white-space:pre-wrap;max-width:100%;display:inline-block;height:auto;padding:${fromPixel(10)} ${fromPixel(20)};background-color:${bgcolor};color:${color.pair(bgcolor)};'>${[].slice.call(parameters, 0).join(", ")}</div>`;
27
+ css(box, `top:${fromPixel(alerts.length ? Math.max.apply(Math, alerts.map(e => e.offsetTop + e.children[0].offsetHeight)) : 0)};height:0;line-height:${fromPixel(singleHeight - 20)};left:0;right:0;font-size:${fromPixel(fontSize)}; transition: all 0.2s ease-out;position:absolute;text-align:center;`);
28
+ box.innerHTML = `<div style='width: 720px;white-space:pre-wrap;max-width:100%;display:inline-block;height:auto;padding:${fromPixel(10)} ${fromPixel(20)};background-color:${bgcolor};color:${color.pair(bgcolor, 1)};'>${[].slice.call(parameters, 0).join(", ")}</div>`;
29
29
  box.initialStyle = `margin:-${fromPixel(singleHeight)} auto;opacity:0;`;
30
30
  return box;
31
31
  };
32
32
  function alert() {
33
- var color = String(isString(this) && this || styles.default), text, autoclose = true, onclose;
34
- var color_reg = /^#(?:\w{6}|\w{3})$/;
33
+ var clr = String(isString(this) && this || styles.default), text, autoclose = true, onclose;
35
34
  [].map.call(arguments, function (arg) {
36
35
  switch (typeof arg) {
37
36
  case "string":
@@ -39,16 +38,16 @@ function alert() {
39
38
  arg = String(arg);
40
39
  if (!text) {
41
40
  text = arg;
42
- } else if (color_reg.test(text)) {
43
- color = text;
41
+ } else if (color.isColor(text)) {
42
+ clr = text;
44
43
  text = arg;
45
44
  } else if (text in styles) {
46
- color = styles[text];
45
+ clr = styles[text];
47
46
  text = arg;
48
47
  } else if (arg in styles) {
49
- color = styles[arg];
50
- } else if (color_reg.test(arg)) {
51
- color = arg;
48
+ clr = styles[arg];
49
+ } else if (color.isColor(arg)) {
50
+ clr = arg;
52
51
  }
53
52
  break;
54
53
  case "boolean":
@@ -61,8 +60,8 @@ function alert() {
61
60
  });
62
61
  var elem;
63
62
 
64
- if (color_reg.test(color)) {
65
- elem = _text(color, [text]);
63
+ if (color.isColor(clr)) {
64
+ elem = _text(clr, [text]);
66
65
  } else {
67
66
  elem = _text(styles.log, [text]);
68
67
  }
@@ -331,13 +331,16 @@ var hooka = function (matcher, move, event, targetChild, isMovingSource) {
331
331
  followedElements.splice(0, followedElements.length);
332
332
  previousElements.push.apply(previousElements, _previousElements);
333
333
  followedElements.push.apply(followedElements, _followedElements);
334
- setOpacity(targetBox, draggingSourceOpacity);
335
334
  appendChild(document.body, previousElements);
336
335
  appendChild(document.body, followedElements);
337
336
  var offall = function () {
337
+ offdragstart();
338
338
  offdragmove();
339
339
  offdragend();
340
340
  };
341
+ var offdragstart = on('dragstart')(targetChild, function () {
342
+ setOpacity(targetBox, draggingSourceOpacity);
343
+ });
341
344
  var offdragend = on("dragend")(targetChild, function () {
342
345
  offall();
343
346
  dragfire();
@@ -71,9 +71,12 @@ var cloneChildren = function (td, copy, clone) {
71
71
  if (after) copy.appendChild(after);
72
72
 
73
73
  };
74
+ /**
75
+ * @param {Node}
76
+ */
74
77
  var isMaybeVisible = function (node) {
75
78
  if (!node || !node.parentNode || node.nodeType > 3 || node.nodeType === 2) return;
76
- if (/^(style|link|script|meta)$/i.test(node)) return;
79
+ if (/^(style|link|script|meta)$/i.test(node.tagName)) return;
77
80
  var style = node.style;
78
81
  if (!style) {
79
82
  node = node.parentNode;
@@ -88,7 +91,6 @@ var isMaybeVisible = function (node) {
88
91
  }
89
92
  if (node.offsetParent) {
90
93
  var parent = node.offsetParent;
91
- if (!isMaybeVisible(parent)) return false;
92
94
  if (getComputedStyle(parent).overflow === 'visible') return true;
93
95
  return !(node.offsetLeft + node.offsetWidth - parent.scrollLeft <= parent.clientLeft ||
94
96
  node.offsetTop + node.offsetHeight - parent.scrollTop <= parent.clientTop ||
@@ -128,9 +130,13 @@ var cloneCanvas = function (canvas) {
128
130
  };
129
131
  var cloneVisible = function (td) {
130
132
  var result = document.createElement("clone");
133
+ if (!isMaybeVisible(td.offsetParent)) return result;
131
134
  var _left, _top, _right, _bottom;
132
135
  var span = document.createElement("x");
133
136
  var hasSvg = false;
137
+ /**
138
+ * @param {Node} td
139
+ */
134
140
  var clone = function (td) {
135
141
  if (!isMaybeVisible(td)) return;
136
142
  if (td.nodeType === 3) {
@@ -346,7 +346,7 @@ var v2rgb = function (v, r, g, b) {
346
346
  return [r, g, b];
347
347
  };
348
348
 
349
- var gray4 = function (RGBA, S) {
349
+ var gray4 = function (RGBA, A) {
350
350
  var [r, g, b, a] = RGBA;
351
351
  var v = rgb2v(r, g, b);
352
352
  var s = rgb2s(r, g, b);
@@ -358,13 +358,18 @@ var gray4 = function (RGBA, S) {
358
358
  else if (v > .6 * 255) {
359
359
  v = v - p * s - p;
360
360
  s = 1;
361
+ if (v < 0) v = - v;
361
362
  }
362
363
  else {
363
364
  v = 255;
364
365
  }
366
+ if (s > .8) {
367
+ r = 255 + r >> 1, g = 255 + g >> 1, b = 255 + b >> 1;
368
+ s = .3;
369
+ }
365
370
  [r, g, b] = rgb4s(r, g, b, s);
366
371
  [r, g, b] = rgb4v(r, g, b, v);
367
- return [r, g, b, a];
372
+ return [r, g, b, A || a];
368
373
  };
369
374
 
370
375
 
@@ -391,8 +396,8 @@ extend(color, {
391
396
  parse,
392
397
  equal,
393
398
  stringify,
394
- pair(c, s) {
395
- return doWith(gray4, c, s);
399
+ pair(c, alpha) {
400
+ return doWith(gray4, c, alpha);
396
401
  },
397
402
  isColor,
398
403
  transform(text) {
@@ -39,7 +39,6 @@ function contextmenu(target, menuItems) {
39
39
  bindtouch(target, {
40
40
  start(event) {
41
41
  if (event.defaultPrevented) return;
42
- event.preventDefault();
43
42
  clearTimeout(menuHandle);
44
43
  if (tm) remove(tm), tm = null;
45
44
  menuHandle = setTimeout(function () {
@@ -66,6 +65,7 @@ function contextmenu(target, menuItems) {
66
65
  event.preventDefault();
67
66
  if (tm) remove(tm), tm = null;
68
67
  tm = showContext(event);
68
+ if (!tm) return;
69
69
  tm.focus();
70
70
  onblur(tm, lazy(e => remove(tm)));
71
71
  });
@@ -62,7 +62,6 @@ function drag(target, initialEvent, preventOverflow, isMovingSource) {
62
62
  if (!onclick.preventClick) return;
63
63
  saved_delta.ing = true;
64
64
  drag.target = target;
65
- dispatch("dragstart", target);
66
65
  if (isElement(target) && !/absolute|fixed/.test(getComputedStyle(target).position)) {
67
66
  clone = toCloneTarget(target, isMovingSource);
68
67
  z = zIndex(0) + 1;
@@ -79,6 +78,7 @@ function drag(target, initialEvent, preventOverflow, isMovingSource) {
79
78
  extraClones.map(c => document.body.appendChild(c));
80
79
  saved_delta.x += clone_left - target_left;
81
80
  saved_delta.y += clone_top - target_top;
81
+ dispatch("dragstart", target);
82
82
  }
83
83
  event.moveLocked = true;
84
84
  drag.target = clone;