efront 3.25.7 → 3.25.11
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/_index.html +1 -1
- package/coms/basic/Item.js +13 -3
- package/coms/basic/Speed.js +36 -17
- package/coms/basic/Tree.js +4 -4
- package/coms/{zimoli → basic}/cancelAnimationFrame.js +1 -0
- package/coms/basic/lazy.js +29 -12
- package/coms/basic/loader.js +12 -9
- package/coms/basic/mark.js +1 -1
- package/coms/basic/mark_test.js +7 -0
- package/coms/basic/renderExpress.js +3 -3
- package/coms/frame/route.js +12 -3
- package/coms/kugou/playList.less +6 -0
- package/coms/zimoli/bindAccesskey.js +13 -5
- package/coms/zimoli/button.js +2 -1
- package/coms/zimoli/getGenerator.js +24 -8
- package/coms/zimoli/getName.js +7 -5
- package/coms/zimoli/hexagon.js +33 -0
- package/coms/zimoli/innerHeight.js +2 -1
- package/coms/zimoli/innerWidth.js +2 -1
- package/coms/zimoli/list.js +146 -17
- package/coms/zimoli/menu.js +7 -3
- package/coms/zimoli/menuItem.html +8 -3
- package/coms/zimoli/menuItem.js +2 -2
- package/coms/zimoli/menuItem.less +3 -2
- package/coms/zimoli/menuList.js +188 -196
- package/coms/zimoli/menuList.less +1 -1
- package/coms/zimoli/moveupon.js +1 -0
- package/coms/zimoli/on.js +54 -16
- package/coms/zimoli/onmousewheel.js +1 -1
- package/coms/zimoli/popup.js +17 -22
- package/coms/zimoli/render.js +7 -5
- package/coms/zimoli/resize.js +1 -0
- package/coms/zimoli/slider.js +23 -9
- package/coms/zimoli/slider_test.js +1 -1
- package/coms/zimoli/table.js +7 -1
- package/coms/zimoli/touchList.js +22 -20
- package/coms/zimoli/vbox.js +11 -8
- package/docs/main.js +3 -0
- package/package.json +2 -2
- package/public/efront.js +1 -1
- package/coms/zimoli/menuList.html +0 -6
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标签中的代码,在编译发布时,这里的代码会自动删除
|
package/coms/basic/Item.js
CHANGED
|
@@ -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
|
-
|
|
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,6 +35,14 @@ 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;
|
package/coms/basic/Speed.js
CHANGED
|
@@ -1,40 +1,46 @@
|
|
|
1
1
|
function inertia(gun) {
|
|
2
|
-
var
|
|
2
|
+
var spd = new Speed;
|
|
3
|
+
var animateIndex = 0;
|
|
4
|
+
var lastTime = 0;
|
|
3
5
|
var _decrease = function () {
|
|
6
|
+
lastTime = Speed.now() - 1;
|
|
7
|
+
_decrease0();
|
|
8
|
+
}
|
|
9
|
+
var _decrease0 = function () {
|
|
4
10
|
if (
|
|
5
11
|
decrease instanceof Function
|
|
6
12
|
) {
|
|
7
|
-
if (!spd.length
|
|
13
|
+
if (!spd.length) return;
|
|
8
14
|
var id = smooth_timer;
|
|
9
|
-
var
|
|
15
|
+
var now = Speed.now();
|
|
16
|
+
var res = decrease(now - lastTime, spd);
|
|
17
|
+
lastTime = now;
|
|
10
18
|
if (smooth_timer !== id) return;
|
|
11
19
|
if (res === false || isEmpty(res)) {
|
|
12
20
|
spd.unset();
|
|
21
|
+
animateIndex = 0;
|
|
13
22
|
return;
|
|
14
23
|
}
|
|
15
|
-
smooth_timer = requestAnimationFrame(
|
|
24
|
+
smooth_timer = requestAnimationFrame(_decrease0);
|
|
16
25
|
}
|
|
17
26
|
};
|
|
18
27
|
var _cancel = function () {
|
|
19
28
|
cancelAnimationFrame(smooth_timer);
|
|
20
|
-
_decreased = 0;
|
|
21
29
|
decrease = null;
|
|
22
30
|
}
|
|
23
31
|
var smooth = function () {
|
|
24
32
|
var args = spd.read();
|
|
25
|
-
if (decrease && args.filter(a => Math.abs(a) > 2).length === 0) {
|
|
26
|
-
_decrease();
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (args.filter(a => Math.abs(a) > .5).length === 0) {
|
|
30
|
-
spd.reset();
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
33
|
var id = smooth_timer;
|
|
34
34
|
var res = gun.apply(that, args);
|
|
35
35
|
if (id !== smooth_timer) return;
|
|
36
36
|
if (false === res) {
|
|
37
37
|
spd.reset();
|
|
38
|
+
animateIndex = 2;
|
|
39
|
+
smooth_timer = requestAnimationFrame(_decrease);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (decrease && args.filter(a => Math.abs(a) > 1).length === 0) {
|
|
43
|
+
animateIndex = 2;
|
|
38
44
|
smooth_timer = requestAnimationFrame(_decrease);
|
|
39
45
|
return;
|
|
40
46
|
}
|
|
@@ -42,6 +48,7 @@ function inertia(gun) {
|
|
|
42
48
|
};
|
|
43
49
|
var spd, smooth_timer, that, decrease;
|
|
44
50
|
var train = function () {
|
|
51
|
+
animateIndex = 1;
|
|
45
52
|
_cancel();
|
|
46
53
|
var args = [].slice.call(arguments, 0, arguments.length);
|
|
47
54
|
spd.write(args);
|
|
@@ -51,7 +58,12 @@ function inertia(gun) {
|
|
|
51
58
|
train.smooth = function (d) {
|
|
52
59
|
_cancel();
|
|
53
60
|
decrease = d;
|
|
54
|
-
|
|
61
|
+
if (animateIndex === 1) {
|
|
62
|
+
smooth_timer = requestAnimationFrame(smooth);
|
|
63
|
+
}
|
|
64
|
+
else if (animateIndex === 2) {
|
|
65
|
+
smooth_timer = requestAnimationFrame(_decrease);
|
|
66
|
+
}
|
|
55
67
|
};
|
|
56
68
|
train.reset = function () {
|
|
57
69
|
_cancel();
|
|
@@ -63,6 +75,7 @@ function inertia(gun) {
|
|
|
63
75
|
class Speed extends Array {
|
|
64
76
|
cache = [];
|
|
65
77
|
stamp = 0;
|
|
78
|
+
deltat = 0;
|
|
66
79
|
static now() {
|
|
67
80
|
return performance.now ? performance.now() : Date.now();
|
|
68
81
|
}
|
|
@@ -103,20 +116,26 @@ class Speed extends Array {
|
|
|
103
116
|
if (this.stamp) ratio = now - this.stamp;
|
|
104
117
|
else ratio = deltat;
|
|
105
118
|
if (ratio > 160) ratio = 1e-3;
|
|
119
|
+
if (this.deltat) {
|
|
120
|
+
if (deltat > this.deltat * 10) {
|
|
121
|
+
ratio = 1e-3;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
this.deltat = deltat;
|
|
106
125
|
this.stamp = now;
|
|
107
126
|
var sum = 0;
|
|
108
127
|
for (var v of values) sum += v * v;
|
|
109
128
|
v = Math.sqrt(sum) * ratio;
|
|
110
129
|
if (v > 1) {
|
|
111
|
-
v = Math.sqrt(v * (v -
|
|
130
|
+
v = Math.sqrt(v * (v - .996)) / v;
|
|
112
131
|
}
|
|
113
132
|
else {
|
|
114
|
-
v =
|
|
133
|
+
v = .9;
|
|
115
134
|
}
|
|
116
135
|
var r = ratio * v;
|
|
117
136
|
for (var cx = 0, dx = values.length; cx < dx; cx++) {
|
|
118
137
|
values[cx] *= r;
|
|
119
|
-
this[cx] *= v;
|
|
138
|
+
if (Math.abs(this[cx]) > .1) this[cx] *= v;
|
|
120
139
|
}
|
|
121
140
|
return values;
|
|
122
141
|
}
|
package/coms/basic/Tree.js
CHANGED
|
@@ -6,7 +6,7 @@ class Tree extends Array {
|
|
|
6
6
|
count = 0;
|
|
7
7
|
total = 0;
|
|
8
8
|
constructor(src) {
|
|
9
|
-
if (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
|
|
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
|
|
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
|
|
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
|
}
|
package/coms/basic/lazy.js
CHANGED
|
@@ -2,25 +2,35 @@
|
|
|
2
2
|
// 2.如果time小于0,传入的函数会立即执行,并忽略-time内的连续调用,time时间后触发最后一次调用
|
|
3
3
|
// 如果time传false或0 使用requestAnimationFrame代替setTimeout按第1步执行
|
|
4
4
|
// 如果time传null或undefined或NaN使用requestAnimationFrame代替setTimeout按第2步执行
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @param {Function} run 主程序
|
|
8
|
+
* @param {number|undefined} time 间隔
|
|
9
|
+
* @param {any} ret 指定调用结束后返回的结果
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
function lazy(run, time, ret) {
|
|
6
13
|
var wait = +time ? setTimeout : requestAnimationFrame;
|
|
7
|
-
var
|
|
14
|
+
var quit = wait === setTimeout ? clearTimeout : cancelAnimationFrame;
|
|
15
|
+
var ing, args, that, id;
|
|
8
16
|
var hire = function () {
|
|
17
|
+
if (!ing) return;
|
|
9
18
|
if (time >= 0) {
|
|
10
|
-
if (ing === true) ing = wait(fire, +time / 2);
|
|
11
|
-
else wait(fire, +time / 2), ing = -2;
|
|
19
|
+
if (ing === true) id = ing = wait(fire, +time / 2);
|
|
20
|
+
else id = wait(fire, +time / 2), ing = -2;
|
|
12
21
|
}
|
|
13
22
|
else {
|
|
14
|
-
wait(fire, -time);
|
|
23
|
+
id = wait(fire, -time);
|
|
15
24
|
}
|
|
16
25
|
};
|
|
17
26
|
var fire = function () {
|
|
27
|
+
if (!ing) return;
|
|
18
28
|
if (time >= 0) {
|
|
19
29
|
if (ing === true) {
|
|
20
|
-
ing = wait(fire, +time / 2);
|
|
30
|
+
id = ing = wait(fire, +time / 2);
|
|
21
31
|
}
|
|
22
32
|
else if (ing > 0) {
|
|
23
|
-
wait(fire, +time / 2);
|
|
33
|
+
id = wait(fire, +time / 2);
|
|
24
34
|
ing = -1;
|
|
25
35
|
}
|
|
26
36
|
else if (ing === -1) {
|
|
@@ -36,27 +46,34 @@ function lazy(run, time) {
|
|
|
36
46
|
if (ing === true) {
|
|
37
47
|
ing = run.apply(that, args);
|
|
38
48
|
if (ing instanceof Promise) ing.then(hire, hire);
|
|
39
|
-
else ing = wait(fire, -time);
|
|
49
|
+
else id = ing = wait(fire, -time);
|
|
40
50
|
} else {
|
|
41
51
|
ing = false;
|
|
42
52
|
}
|
|
43
53
|
}
|
|
44
54
|
};
|
|
45
|
-
|
|
55
|
+
var exec = function () {
|
|
46
56
|
args = arguments;
|
|
47
57
|
that = this;
|
|
48
58
|
if (ing) return ing = true;
|
|
49
59
|
if (time >= 0) {
|
|
50
|
-
ing = wait(fire, +time);
|
|
60
|
+
id = ing = wait(fire, +time);
|
|
51
61
|
}
|
|
52
62
|
else if (time < 0) {
|
|
53
63
|
ing = run.apply(that, args);
|
|
54
64
|
if (ing instanceof Promise) ing.then(hire, hire);
|
|
55
|
-
else ing = wait(fire, -time);
|
|
65
|
+
else id = ing = wait(fire, -time);
|
|
56
66
|
}
|
|
57
67
|
else {
|
|
58
|
-
ing = true; wait(fire);
|
|
68
|
+
ing = true; id = wait(fire);
|
|
59
69
|
}
|
|
70
|
+
return ret;
|
|
60
71
|
};
|
|
72
|
+
exec.cancel = function () {
|
|
73
|
+
quit(id);
|
|
74
|
+
ing = false;
|
|
75
|
+
id = 0;
|
|
76
|
+
};
|
|
77
|
+
return exec;
|
|
61
78
|
}
|
|
62
79
|
module.exports = lazy;
|
package/coms/basic/loader.js
CHANGED
|
@@ -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");
|
|
@@ -168,7 +169,7 @@ var killCircle = function () {
|
|
|
168
169
|
if (k.slice(0, keyprefix.length) === keyprefix && loadedModules[k] instanceof Array) {
|
|
169
170
|
var key = k.slice(keyprefix.length);
|
|
170
171
|
var args = loadedModules[k].args;
|
|
171
|
-
if (loadedModules[k] instanceof Array) continue;
|
|
172
|
+
if (!(loadedModules[k] instanceof Array)) continue;
|
|
172
173
|
args.forEach(arg => {
|
|
173
174
|
if (!penddings[arg]) {
|
|
174
175
|
penddings[arg] = [];
|
|
@@ -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
|
-
|
|
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
|
});
|
package/coms/basic/mark.js
CHANGED
|
@@ -69,7 +69,7 @@ var power = function (source, search) {
|
|
|
69
69
|
var pp = 0, ap = 0;
|
|
70
70
|
var p = match_text.length;
|
|
71
71
|
p = match_text.length;
|
|
72
|
-
if (match_start2) p += .1 / match_start2;
|
|
72
|
+
if (match_start2) p += .1 / match_start2 - .2;
|
|
73
73
|
if (match_text_pre.length > 1) {
|
|
74
74
|
[pp, match_text_pre] = power(match_text_pre, search);
|
|
75
75
|
}
|
|
@@ -11,8 +11,8 @@ function createSeek(express) {
|
|
|
11
11
|
return dist;
|
|
12
12
|
}
|
|
13
13
|
function main(express) {
|
|
14
|
-
if (!/\?\s*\.(?=[^\d])
|
|
15
|
-
var reg = /\\[\s\S]|\?\s*(\.(?!\d)
|
|
14
|
+
if (!/\?\s*\.(?=[^\d])|\?\s*[\?\]\}\)\:\,=|%&;\>\<]|\?\s*$/.test(express)) return express;
|
|
15
|
+
var reg = /\\[\s\S]|\?\s*(\.(?!\d)|$|(?=[\?\]\}\)\:\,=|%&;\>\<\*\/]))|[\:\,\+\=\-\!%\^\|\/\&\*\!\;\?\>\<~\{\}\[\]\(\)'"`\s]/g;
|
|
16
16
|
var cache = [], queue = [];
|
|
17
17
|
var exp = [];
|
|
18
18
|
var instr = false;
|
|
@@ -71,7 +71,7 @@ function main(express) {
|
|
|
71
71
|
if (instr) {
|
|
72
72
|
continue;
|
|
73
73
|
}
|
|
74
|
-
if (/['"
|
|
74
|
+
if (/['"`\/]/.test(m)) {
|
|
75
75
|
isstr = true;
|
|
76
76
|
index++;
|
|
77
77
|
}
|
package/coms/frame/route.js
CHANGED
|
@@ -27,14 +27,17 @@
|
|
|
27
27
|
if (/,/.test(k)) {
|
|
28
28
|
var [k, ...roles] = k.split(',');
|
|
29
29
|
}
|
|
30
|
-
if (!icon &&
|
|
30
|
+
if (!icon && /(?!\.)\.(?=[\w\-])/.test(k)) {
|
|
31
|
+
icon = k.slice(k.indexOf(/(?!\.)\.(?=[\w\-])/));
|
|
32
|
+
}
|
|
33
|
+
if (!icon && /\s+/.test(k)) {
|
|
31
34
|
[icon] = k.split(/\s+/);
|
|
32
35
|
k = k.slice(icon.length).trim();
|
|
33
36
|
}
|
|
34
37
|
if (!name) name = k;
|
|
35
38
|
var item = {};
|
|
36
39
|
if (icon) item.icon = icon.replace(/\./g, ' ');
|
|
37
|
-
|
|
40
|
+
item.name = name;
|
|
38
41
|
if (hotkey) {
|
|
39
42
|
hotkey = hotkey.split(',');
|
|
40
43
|
for (var k of hotkey) {
|
|
@@ -108,6 +111,8 @@
|
|
|
108
111
|
if (path) item.path = path;
|
|
109
112
|
if (data) item.params = parseKV(data);
|
|
110
113
|
item.closed = true;
|
|
114
|
+
if (filter) var item0 = filter(item);
|
|
115
|
+
if (item0) item = item0;
|
|
111
116
|
return item;
|
|
112
117
|
});
|
|
113
118
|
return items;
|
|
@@ -231,10 +236,14 @@
|
|
|
231
236
|
result.then = then;
|
|
232
237
|
return result;
|
|
233
238
|
};
|
|
234
|
-
|
|
239
|
+
var filter = null;
|
|
240
|
+
result.parse = function (items, f) {
|
|
241
|
+
filter = f;
|
|
235
242
|
keymap = {};
|
|
236
243
|
items = parseMenuList(items);
|
|
237
244
|
items.keymap = keymap;
|
|
245
|
+
filter = null;
|
|
246
|
+
keymap = null;
|
|
238
247
|
return items;
|
|
239
248
|
};
|
|
240
249
|
var then = function (ok, oh) {
|
package/coms/kugou/playList.less
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
var keyMap = {};
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* @param {KeyboardEvent} event
|
|
4
|
+
*/
|
|
5
|
+
var keydownhandler = function (event) {
|
|
6
|
+
if (event.defaultPrevented) return;
|
|
3
7
|
var { which } = event;
|
|
4
8
|
switch (event.which) {
|
|
5
|
-
case 18:
|
|
9
|
+
case 18: // alt
|
|
6
10
|
event.preventDefault();
|
|
7
11
|
break;
|
|
8
12
|
default:
|
|
@@ -16,12 +20,15 @@ on("keydown")(window, function (event) {
|
|
|
16
20
|
if (elem) {
|
|
17
21
|
var parent = elem.parentNode;
|
|
18
22
|
if (event.altKey || parent === document.activeElement || parent.ispop) {
|
|
19
|
-
event.
|
|
20
|
-
|
|
23
|
+
if (!(event.metaKey || event.shiftKey || event.ctrlKey)) {
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
elem.click();
|
|
26
|
+
}
|
|
21
27
|
}
|
|
22
28
|
}
|
|
23
29
|
}
|
|
24
|
-
}
|
|
30
|
+
}
|
|
31
|
+
on("keydown")(window, keydownhandler);
|
|
25
32
|
var bindAccesskey = function (btn, k) {
|
|
26
33
|
if (!keyMap[k]) keyMap[k] = [];
|
|
27
34
|
removeFromList(keyMap[k], btn);
|
|
@@ -42,6 +49,7 @@ var getKeyFromText = function (btn) {
|
|
|
42
49
|
return accesskey.toUpperCase();
|
|
43
50
|
}
|
|
44
51
|
function main(elem, key = getKeyFromText(elem)) {
|
|
52
|
+
if (!key) return;
|
|
45
53
|
bindAccesskey(elem, key);
|
|
46
54
|
return elem;
|
|
47
55
|
}
|
package/coms/zimoli/button.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
var _label = createElement("span");
|
|
2
2
|
var track = createElement(div);
|
|
3
|
+
var onmouseenter = on("mouseenter");
|
|
3
4
|
track.className = "track";
|
|
4
5
|
_label.className = "label";
|
|
5
6
|
|
|
@@ -107,7 +108,7 @@ function button(texter, type) {
|
|
|
107
108
|
button = button || createElement(btn, tracker, _texter);
|
|
108
109
|
bindAccesskey(button);
|
|
109
110
|
onremove(button, resetall);
|
|
110
|
-
|
|
111
|
+
onmouseenter(button, hover);
|
|
111
112
|
onmouseleave(button, mouseleave);
|
|
112
113
|
onmousemove(button, mousemove);
|
|
113
114
|
onmousedown(button, mousedown);
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
|
|
2
2
|
var _slider = createElement(div);
|
|
3
|
+
/**
|
|
4
|
+
* @param {Element} container
|
|
5
|
+
* @param {Element|string} tagName;
|
|
6
|
+
*/
|
|
3
7
|
var getGenerator = function (container, tagName = 'item') {
|
|
4
8
|
if (!container) return;
|
|
5
9
|
var scopes = container.$parentScopes || [];
|
|
6
10
|
if (container.$scope) scopes = scopes.concat(container.$scope);
|
|
7
11
|
container.$generatorScopes = scopes;
|
|
8
12
|
if (container.$generator) return container.$generator;
|
|
9
|
-
var template = document.createElement(tagName);
|
|
13
|
+
var template = document.createElement(container.tagName);
|
|
10
14
|
var templates = [].concat.apply([], container.childNodes).filter(a => {
|
|
11
15
|
if (a.hasAttribute('insert')) {
|
|
12
16
|
return false;
|
|
@@ -22,22 +26,34 @@ var getGenerator = function (container, tagName = 'item') {
|
|
|
22
26
|
container.paddingCount = paddingCount;
|
|
23
27
|
}
|
|
24
28
|
appendChild(template, templates);
|
|
29
|
+
if (templates.length) container.$template = template;
|
|
25
30
|
container.insertBefore = _slider.insertBefore;
|
|
26
31
|
container.appendChild = _slider.appendChild;
|
|
32
|
+
/**
|
|
33
|
+
* @param {number} index;
|
|
34
|
+
* @param {Object} com;
|
|
35
|
+
* @param {Element} element;
|
|
36
|
+
*/
|
|
27
37
|
return container.$generator = function (index, com, element) {
|
|
28
38
|
if (com === undefined) {
|
|
29
39
|
if (!container.src || index >= container.src.length) return;
|
|
30
40
|
com = container.src[index];
|
|
31
41
|
}
|
|
32
42
|
if (com === undefined) return;
|
|
33
|
-
|
|
43
|
+
var needSetAttr = isElement(tagName);
|
|
44
|
+
if (isNode(element));
|
|
45
|
+
else if (!template.childNodes.length) {
|
|
46
|
+
element = needSetAttr ? tagName.cloneNode(true) : document.createElement(tagName);
|
|
47
|
+
needSetAttr = false;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
34
50
|
var template1 = template.cloneNode(true);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
51
|
+
element = template1.childNodes[0];
|
|
52
|
+
if (template1.childNodes.length > 1) element.with = [].concat.apply([], template1.childNodes).slice(1);
|
|
53
|
+
}
|
|
54
|
+
if (needSetAttr) {
|
|
55
|
+
for (var a of tagName.attributes) {
|
|
56
|
+
element.setAttribute(a.name, a.value);
|
|
41
57
|
}
|
|
42
58
|
}
|
|
43
59
|
var scopes = container.$generatorScopes;
|
package/coms/zimoli/getName.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
var hasOwnProperty = {}.hasOwnProperty;
|
|
2
|
+
var keys = ["name", 'title', 'label', 'value'];
|
|
2
3
|
function getName(o) {
|
|
3
4
|
var name;
|
|
4
5
|
if (isEmpty(o)) return '';
|
|
@@ -7,11 +8,12 @@ function getName(o) {
|
|
|
7
8
|
name = o.toString();
|
|
8
9
|
if (!isEmpty(name)) return String(name);
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
for (var k of keys) {
|
|
12
|
+
if (!hasOwnProperty.call(o, k)) continue;
|
|
13
|
+
if (!isEmpty(o[k])) return String(o[k]);
|
|
14
|
+
if (isString(o[k])) name = o[k];
|
|
15
|
+
}
|
|
14
16
|
if (hasOwnProperty.call(o, 'valueOf')) name = o.valueOf();
|
|
15
|
-
if (
|
|
17
|
+
if (isString(name)) return name;
|
|
16
18
|
return String(o);
|
|
17
19
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var hexagon = function (c = "#fff", lineWidth = devicePixelRatio) {
|
|
2
|
+
var image = document.createElement('canvas');
|
|
3
|
+
image.width = 9 * lineWidth;
|
|
4
|
+
image.height = 16 * lineWidth;
|
|
5
|
+
image.src = true;
|
|
6
|
+
var { width, height } = image;
|
|
7
|
+
var w = width;
|
|
8
|
+
var h = height;
|
|
9
|
+
|
|
10
|
+
var ctx = image.getContext("2d");
|
|
11
|
+
ctx.beginPath();
|
|
12
|
+
var cx = lineWidth / 2;
|
|
13
|
+
var cy = 0;
|
|
14
|
+
ctx.moveTo(cx, cy);
|
|
15
|
+
/* | */ctx.lineTo(cx, cy + h / 6);
|
|
16
|
+
/* \ */ctx.lineTo(cx + w / 2, cy + h / 3);
|
|
17
|
+
/* | */ctx.lineTo(cx + w / 2, cy + h * 2 / 3);
|
|
18
|
+
/* / */ctx.lineTo(cx, cy + h * 5 / 6);
|
|
19
|
+
/* | */ctx.lineTo(cx, cy + h);
|
|
20
|
+
ctx.moveTo(cx + w / 2, cy + h / 3);
|
|
21
|
+
/* / */ctx.lineTo(cx + w, cy + h / 6);
|
|
22
|
+
ctx.moveTo(cx + w / 2, cy + h * 2 / 3);
|
|
23
|
+
/* \ */ctx.lineTo(cx + w, cy + h * 5 / 6);
|
|
24
|
+
ctx.moveTo(cx, cy + h / 6);
|
|
25
|
+
ctx.lineTo(cx - w / 2, cy + h / 3);
|
|
26
|
+
ctx.moveTo(cx - w / 2, cy + h * 2 / 3);
|
|
27
|
+
ctx.lineTo(cx, cy + h * 5 / 6);
|
|
28
|
+
ctx.strokeStyle = c;
|
|
29
|
+
ctx.lineWidth = lineWidth;
|
|
30
|
+
ctx.stroke();
|
|
31
|
+
image.complete = true;
|
|
32
|
+
return image;
|
|
33
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
var document = this.document;
|
|
2
2
|
|
|
3
3
|
function innerHeight() {
|
|
4
|
-
|
|
4
|
+
if (isFinite(window.innerHeight)) return window.innerHeight;
|
|
5
|
+
return document.documentElement.offsetHeight || document.body && document.body.offsetHeight;
|
|
5
6
|
}
|
|
6
7
|
innerHeight.toString = function () {
|
|
7
8
|
return this().toString();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
var document = this.document;
|
|
2
2
|
function innerWidth() {
|
|
3
|
-
|
|
3
|
+
if (isFinite(window.innerWidth)) return window.innerWidth;
|
|
4
|
+
return document.documentElement.offsetWidth || document.body && document.body.offsetWidth;
|
|
4
5
|
}
|
|
5
6
|
innerWidth.toString = function () {
|
|
6
7
|
return this().toString();
|