efront 3.11.1 → 3.12.0
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/kugou/api.js +10 -7
- package/apps/pivot/link/list.html +1 -1
- package/apps/pivot/link/list.js +2 -2
- package/coms/basic/parseYML.js +1 -1
- package/coms/frame/route.js +28 -3
- package/coms/kugou/parseSongsList.js +24 -10
- package/coms/zimoli/Item.js +1 -0
- package/coms/zimoli/button.less +3 -2
- package/coms/zimoli/getGenerator.js +20 -17
- package/coms/zimoli/menu.js +3 -2
- package/coms/zimoli/menu.less +49 -80
- package/coms/zimoli/menuItem.js +2 -0
- package/coms/zimoli/menuItem.less +16 -0
- package/coms/zimoli/menuList.js +35 -26
- package/coms/zimoli/menuList.less +6 -2
- package/coms/zimoli/model.js +5 -3
- package/coms/zimoli/render.js +14 -12
- package/coms/zimoli/selectList.js +10 -4
- package/coms/zimoli/selectList.less +1 -1
- package/coms/zimoli/tree.js +7 -5
- package/coms/zimoli/tree.less +14 -1
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/apps/kugou/api.js
CHANGED
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
"https://m.kugou.com/": {
|
|
3
3
|
"song-info": "get app/i/getSongInfo.php?cmd=playInfo&from=mkugou&hash",
|
|
4
4
|
"slider-src": "get:[].mod-slider>.swipe-wrap>div .#src=img!src&href=a!href",
|
|
5
|
-
"songs-list": "get:[].panel-songslist
|
|
6
|
-
"rank-list": "get:[].panel-img-list
|
|
7
|
-
"rank-info": "get:[].panel-songslist
|
|
8
|
-
"plist-index": "get:[].panel-img-list
|
|
9
|
-
"plist-info": "get:[].panel-songslist
|
|
5
|
+
"songs-list": "get:[].panel-songslist%20li .#hash=!id&.panel-songs-item-name>span!innerText",
|
|
6
|
+
"rank-list": "get:[].panel-img-list%20li rank/list#href=a!href&=a!href\\rank-info&imgurl=img!_src&name=p|innerText",
|
|
7
|
+
"rank-info": "get:[].panel-songslist%20li rank/info/:id#src=!id&name=.panel-songs-item-name|innerText&data=.panel-songs-item-download/innerText",
|
|
8
|
+
"plist-index": "get:[].panel-img-list%20li plist/index#href=a!href&=a!href\\plist-info&imgurl=img!_src&name=.panel-img-content-first|innerText&count=.panel-img-content-sub|innerText",
|
|
9
|
+
"plist-info": "get:[].panel-songslist%20li plist/list/:id#name=.panel-songs-item-name|innerText&data=.panel-songs-item-download/innerText",
|
|
10
10
|
"search-hot": "get api/v3/search/hot?format=json&plat=0&count=30",
|
|
11
11
|
"singer-class": "get:[].bd%20li singer/class#href=a!href&=a!href\\singer-list&name=a|innerText&group=?parentNode",
|
|
12
|
-
"singer-list": "get:[].singer-img-list>li singer/list/:id#href=a!href&=a!href\\singer-
|
|
13
|
-
"singer-
|
|
12
|
+
"singer-list": "get:[].singer-img-list>li singer/list/:id#href=a!href&=a!href\\singer-info0&imgurl=img!_src&name=p|innerText",
|
|
13
|
+
"singer-info0": "mget:[].singer-songs-list>li singer/info/:id#hash=!id&singer=.singer-name|innerText&name=.song-name|innerText&data=em/innerText"
|
|
14
|
+
},
|
|
15
|
+
"https://www.kugou.com/": {
|
|
16
|
+
"singer-info": "cget:link[rel]+script yy/singer/home/:id.html",
|
|
14
17
|
},
|
|
15
18
|
"http://mobilecdn.kugou.com/": {
|
|
16
19
|
"search?keyword": "get:data.info api/v3/search/song?format=json&page=1&pagesize=30&showtype=1"
|
package/apps/pivot/link/list.js
CHANGED
|
@@ -7,13 +7,13 @@ function main() {
|
|
|
7
7
|
await this.clusters;
|
|
8
8
|
this.active();
|
|
9
9
|
},
|
|
10
|
-
index: data.getInstance("index")
|
|
10
|
+
index: data.getInstance("index"),
|
|
11
11
|
clusters: [],
|
|
12
12
|
filterTime(d) {
|
|
13
13
|
return ((new Date - d) / 1000 | 0) + "秒";
|
|
14
14
|
},
|
|
15
15
|
clients: [],
|
|
16
|
-
active(index = this.index) {
|
|
16
|
+
active(index = this.index.index | 0) {
|
|
17
17
|
data.setInstance('index', { index });
|
|
18
18
|
var clusters = this.clusters;
|
|
19
19
|
if (index >= clusters.length) index = clusters.length - 1;
|
package/coms/basic/parseYML.js
CHANGED
package/coms/frame/route.js
CHANGED
|
@@ -33,10 +33,23 @@
|
|
|
33
33
|
};
|
|
34
34
|
var parseMenuList = function (items) {
|
|
35
35
|
if (items instanceof Array) {
|
|
36
|
+
if (!items[0] || !items[0].name) {
|
|
37
|
+
var items1 = [];
|
|
38
|
+
for (var cx = 0, dx = items.length; cx < dx; cx++) {
|
|
39
|
+
var item = items[cx];
|
|
40
|
+
if (!item) continue;
|
|
41
|
+
item = parseMenuList(item);
|
|
42
|
+
items1.push.apply(items1, item);
|
|
43
|
+
items1.push({ line: true });
|
|
44
|
+
}
|
|
45
|
+
items1.pop();
|
|
46
|
+
items = items1;
|
|
47
|
+
}
|
|
36
48
|
return items;
|
|
37
49
|
}
|
|
38
50
|
if (items instanceof Object) {
|
|
39
51
|
var keys = Object.keys(items);
|
|
52
|
+
|
|
40
53
|
items = keys.map(k => {
|
|
41
54
|
var c = items[k];
|
|
42
55
|
var item = {};
|
|
@@ -54,7 +67,8 @@
|
|
|
54
67
|
if (/,/.test(name)) {
|
|
55
68
|
var [name, ...roles] = name.split(',');
|
|
56
69
|
}
|
|
57
|
-
item.
|
|
70
|
+
if (/^\-+$/.test(name)) item.line = true;
|
|
71
|
+
else item.name = name;
|
|
58
72
|
if (roles) item.roles = roles;
|
|
59
73
|
if (path) item.path = path;
|
|
60
74
|
if (data) item.params = parseKV(data);
|
|
@@ -68,6 +82,8 @@
|
|
|
68
82
|
return [];
|
|
69
83
|
};
|
|
70
84
|
result.update = function (items) {
|
|
85
|
+
delete result.loading_promise;
|
|
86
|
+
delete result.then;
|
|
71
87
|
items = parseMenuList(items);
|
|
72
88
|
items.map(getChildren);
|
|
73
89
|
var opened = data.getInstance("menu-opened");
|
|
@@ -174,10 +190,19 @@
|
|
|
174
190
|
result.load(result.active);
|
|
175
191
|
return result;
|
|
176
192
|
};
|
|
177
|
-
result.fetch = function (url) {
|
|
178
|
-
data.from(url).loading_promise.then(result.update);
|
|
193
|
+
result.from = result.fetch = function (url) {
|
|
194
|
+
result.loading_promise = data.from(url).loading_promise.then(result.update);
|
|
195
|
+
result.then = then;
|
|
179
196
|
return result;
|
|
180
197
|
};
|
|
198
|
+
var then = function (ok, oh) {
|
|
199
|
+
if (this.loading_promise) {
|
|
200
|
+
return this.loading_promise.then(ok, oh);
|
|
201
|
+
}
|
|
202
|
+
delete result.then;
|
|
203
|
+
ok(result);
|
|
204
|
+
result.then = then;
|
|
205
|
+
};
|
|
181
206
|
result.update(items);
|
|
182
207
|
return result;
|
|
183
208
|
});
|
|
@@ -1,10 +1,24 @@
|
|
|
1
|
-
a =>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return
|
|
10
|
-
}
|
|
1
|
+
a => {
|
|
2
|
+
if (isElement(a)) {
|
|
3
|
+
var m = /songsdata\s*=\s*(\[[\s\S]*\])/.exec(a.innerText);
|
|
4
|
+
if (!m) throw new Error("无法加载数据!");
|
|
5
|
+
if (m) a = m[1];
|
|
6
|
+
a = JSON.parse(a);
|
|
7
|
+
console.log(a)
|
|
8
|
+
}
|
|
9
|
+
return a.map(b => {
|
|
10
|
+
var data = {};
|
|
11
|
+
if (b.data) extend(data, {
|
|
12
|
+
name: b.data.filename.replace(/^[\s\S]*?\s*\-\s*/, ''),
|
|
13
|
+
singer: b.data.filename.replace(/\s*\-\s*[\s\S]*?$/, '')
|
|
14
|
+
}, b.data);
|
|
15
|
+
else extend(data, b);
|
|
16
|
+
if (!data.singer) {
|
|
17
|
+
data.singer = data.author_name;
|
|
18
|
+
}
|
|
19
|
+
if (!data.name) data.name = data.audio_name;
|
|
20
|
+
if (data.hash) data.hash = data.hash.replace(/^songs\_/i, '');
|
|
21
|
+
return data;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
}
|
package/coms/zimoli/Item.js
CHANGED
package/coms/zimoli/button.less
CHANGED
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
outline: none;
|
|
19
19
|
user-select: none;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
|
|
22
|
+
>.label {
|
|
22
23
|
position: relative;
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -91,7 +92,7 @@
|
|
|
91
92
|
|
|
92
93
|
>.track {
|
|
93
94
|
background: #0001;
|
|
94
|
-
box-shadow: inset 0 0 6px 6px #
|
|
95
|
+
box-shadow: inset 0 0 6px 6px #00000006;
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
var _slider = createElement(div);
|
|
3
|
-
var
|
|
4
|
-
if (!item) return;
|
|
5
|
-
return document.createElement('empty');
|
|
6
|
-
};
|
|
7
|
-
var getGenerator = function (container) {
|
|
3
|
+
var getGenerator = function (container, tagName = 'item') {
|
|
8
4
|
if (!container) return;
|
|
9
|
-
if (!container.childNodes.length) return container.$generator
|
|
10
|
-
var template = document.createElement(
|
|
5
|
+
if (!container.childNodes.length && container.$generator) return container.$generator;
|
|
6
|
+
var template = document.createElement(tagName);
|
|
11
7
|
var templates = [].concat.apply([], container.childNodes).filter(a => {
|
|
12
8
|
if (a.hasAttribute('insert')) {
|
|
13
9
|
return false;
|
|
@@ -25,17 +21,24 @@ var getGenerator = function (container) {
|
|
|
25
21
|
appendChild(template, templates);
|
|
26
22
|
container.insertBefore = _slider.insertBefore;
|
|
27
23
|
container.appendChild = _slider.appendChild;
|
|
28
|
-
var scopes = container.$parentScopes
|
|
29
|
-
|
|
24
|
+
var scopes = container.$parentScopes || [];
|
|
25
|
+
if (container.$scope) scopes = scopes.concat(container.$scope);
|
|
26
|
+
return container.$generator = function (index, com, element) {
|
|
30
27
|
if (!com) {
|
|
31
28
|
if (!container.src || index >= container.src.length) return;
|
|
32
29
|
com = container.src[index];
|
|
33
30
|
}
|
|
34
31
|
if (!com) return;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
if (!element) {
|
|
33
|
+
var template1 = template.cloneNode(true);
|
|
34
|
+
if (!template1.childNodes.length) {
|
|
35
|
+
element = template1;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
element = template1.childNodes[0];
|
|
39
|
+
if (template1.childNodes.length > 1) element.with = [].concat.apply([], template1.childNodes).slice(1);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
39
42
|
var parsedSrc = container.$src;
|
|
40
43
|
if (parsedSrc) {
|
|
41
44
|
var { keyName, itemName, indexName } = parsedSrc;
|
|
@@ -44,8 +47,8 @@ var getGenerator = function (container) {
|
|
|
44
47
|
[itemName || '$item']: com,
|
|
45
48
|
[indexName || '$index']: index
|
|
46
49
|
};
|
|
47
|
-
var newItem = render(
|
|
48
|
-
if (
|
|
50
|
+
var newItem = render(element, newScope, scopes);
|
|
51
|
+
if (element.with) newItem.with = render(element.with, newScope, scopes);
|
|
49
52
|
} else {
|
|
50
53
|
var newScope = container.src[index];
|
|
51
54
|
if (!isObject(newScope)) newScope = {
|
|
@@ -65,8 +68,8 @@ var getGenerator = function (container) {
|
|
|
65
68
|
return this.$item;
|
|
66
69
|
}
|
|
67
70
|
}
|
|
68
|
-
var newItem = render(
|
|
69
|
-
newItem.with = render(newItem.with =
|
|
71
|
+
var newItem = render(element, newScope, scopes);
|
|
72
|
+
if (element.with) newItem.with = render(newItem.with = element.with, newScope, scopes);
|
|
70
73
|
}
|
|
71
74
|
return newItem;
|
|
72
75
|
};
|
package/coms/zimoli/menu.js
CHANGED
|
@@ -117,8 +117,9 @@ function main(elem, mode) {
|
|
|
117
117
|
case "inline":
|
|
118
118
|
case "t":
|
|
119
119
|
case "tree":
|
|
120
|
+
mode = "tree";
|
|
120
121
|
if (elem) {
|
|
121
|
-
var generator = getGenerator(elem);
|
|
122
|
+
var generator = getGenerator(elem, 'menu-item');
|
|
122
123
|
tree(elem, function (index, item) {
|
|
123
124
|
var e = generator(index, item);
|
|
124
125
|
if (!e || e.children.length) return e;
|
|
@@ -156,7 +157,7 @@ function main(elem, mode) {
|
|
|
156
157
|
active(elem, item, item.value, target);
|
|
157
158
|
};
|
|
158
159
|
if ("$src" in elem) {
|
|
159
|
-
getGenerator(elem);
|
|
160
|
+
getGenerator(elem, 'menu-item');
|
|
160
161
|
care(elem, function (src) {
|
|
161
162
|
menuList(elem, getTreeFromData(src), emit, direction);
|
|
162
163
|
elem.registerAsRoot();
|
package/coms/zimoli/menu.less
CHANGED
|
@@ -92,12 +92,15 @@ body:active & {
|
|
|
92
92
|
display: block;
|
|
93
93
|
overflow: hidden;
|
|
94
94
|
text-overflow: hidden;
|
|
95
|
-
line-height: 40px;
|
|
96
95
|
position: relative;
|
|
97
96
|
border-bottom: 1px solid #18333c;
|
|
97
|
+
border-top: none;
|
|
98
|
+
border-left: none;
|
|
99
|
+
border-right: none;
|
|
98
100
|
padding: 0;
|
|
99
101
|
|
|
100
102
|
menu-item {
|
|
103
|
+
line-height: 24px;
|
|
101
104
|
display: inline-block;
|
|
102
105
|
|
|
103
106
|
&.has-children:after {
|
|
@@ -110,11 +113,9 @@ body:active & {
|
|
|
110
113
|
vertical-align: top;
|
|
111
114
|
}
|
|
112
115
|
|
|
113
|
-
.button {
|
|
114
|
-
line-height: 40px;
|
|
115
|
-
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
&[mode=tree],
|
|
118
119
|
&[mode=tree],
|
|
119
120
|
&[type=tree],
|
|
120
121
|
&[mode=inline],
|
|
@@ -122,46 +123,46 @@ body:active & {
|
|
|
122
123
|
height: auto;
|
|
123
124
|
box-shadow: none;
|
|
124
125
|
padding: 0;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
126
|
+
|
|
127
|
+
>.button {
|
|
128
|
+
box-shadow: none;
|
|
129
|
+
padding-top: 6px;
|
|
130
|
+
padding-bottom: 6px;
|
|
131
|
+
line-height: 20px;
|
|
132
|
+
font-size: 14px;
|
|
133
|
+
|
|
134
|
+
>b {
|
|
135
|
+
font-weight: normal;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
&:not(.tab1) {
|
|
139
|
+
display: block;
|
|
140
|
+
background: #2c3b41;
|
|
141
|
+
color: #8aa4af;
|
|
142
|
+
|
|
143
|
+
&.checked,
|
|
144
|
+
&.actived,
|
|
145
|
+
&.selected {
|
|
146
|
+
color: #fff;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
i {
|
|
151
|
+
margin-right: 10px;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
&.hover {
|
|
156
|
+
text-shadow: none;
|
|
157
|
+
color: #fff;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
>.tab1 {
|
|
163
|
+
font-size: 16px;
|
|
164
|
+
line-height: 28px;
|
|
165
|
+
|
|
165
166
|
&.open {
|
|
166
167
|
color: #fff;
|
|
167
168
|
background: #1e282c;
|
|
@@ -218,45 +219,13 @@ body:active & {
|
|
|
218
219
|
|
|
219
220
|
border-left: 3px solid transparent;
|
|
220
221
|
display : block;
|
|
221
|
-
height : 44px;
|
|
222
|
-
line-height: 44px;
|
|
223
222
|
font-size : 14px;
|
|
224
223
|
color : #b8c7ce;
|
|
225
224
|
}
|
|
226
225
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
>b {
|
|
232
|
-
font-weight: normal;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
&:not(.tab1) {
|
|
236
|
-
display: block;
|
|
237
|
-
height: 36px;
|
|
238
|
-
line-height: 36px;
|
|
239
|
-
font-size: 14px;
|
|
240
|
-
background: #2c3b41;
|
|
241
|
-
color: #8aa4af;
|
|
242
|
-
|
|
243
|
-
&.checked,
|
|
244
|
-
&.actived,
|
|
245
|
-
&.selected {
|
|
246
|
-
color: #fff;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
i {
|
|
251
|
-
margin-right: 10px;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
&.hover {
|
|
256
|
-
text-shadow: none;
|
|
257
|
-
color: #fff;
|
|
258
|
-
}
|
|
259
|
-
|
|
226
|
+
>[line],
|
|
227
|
+
>.line {
|
|
228
|
+
line-height: 0;
|
|
229
|
+
font-size: 0;
|
|
260
230
|
}
|
|
261
|
-
|
|
262
231
|
}
|
package/coms/zimoli/menuItem.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var preventDefault = function (e) { e.preventDefault() };
|
|
1
2
|
function main(elem, scope, hasIcon) {
|
|
2
3
|
var item = elem || document.createElement('menu-item');
|
|
3
4
|
item.innerHTML = menuItem;
|
|
@@ -11,5 +12,6 @@ function main(elem, scope, hasIcon) {
|
|
|
11
12
|
var icon = scope.icon;
|
|
12
13
|
if (hasIcon === undefined) hasIcon = !!icon;
|
|
13
14
|
render(item.children, { useIcon: hasIcon, hasIcon, name, icon });
|
|
15
|
+
if (scope.line) item.setAttribute("line", ''), on("click")(item, preventDefault);
|
|
14
16
|
return item;
|
|
15
17
|
}
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
i{
|
|
2
2
|
display: inline-block;
|
|
3
3
|
width: 1em;
|
|
4
|
+
}
|
|
5
|
+
&.line,
|
|
6
|
+
&[line] {
|
|
7
|
+
box-shadow: none;
|
|
8
|
+
>.track{
|
|
9
|
+
display: none;
|
|
10
|
+
}
|
|
11
|
+
line-height: 0;
|
|
12
|
+
font-size: 0;
|
|
13
|
+
&:after {
|
|
14
|
+
content: "";
|
|
15
|
+
display: block;
|
|
16
|
+
border-bottom: 1px solid;
|
|
17
|
+
opacity: .36;
|
|
18
|
+
margin: 0 -20px;
|
|
19
|
+
}
|
|
4
20
|
}
|
package/coms/zimoli/menuList.js
CHANGED
|
@@ -11,10 +11,11 @@ var clear = function () {
|
|
|
11
11
|
var unfocus = function () {
|
|
12
12
|
remove(mounted_menus);
|
|
13
13
|
this.ispop = false;
|
|
14
|
+
this.setFocus(null);
|
|
14
15
|
};
|
|
15
|
-
var setFocus = function (focused
|
|
16
|
+
var setFocus = function (focused) {
|
|
16
17
|
var page = this;
|
|
17
|
-
if (
|
|
18
|
+
if (focused) {
|
|
18
19
|
if (page.focused !== focused) {
|
|
19
20
|
if (page.focused) removeClass(page.focused, 'focus');
|
|
20
21
|
if (focused) addClass(focused, "focus");
|
|
@@ -105,12 +106,18 @@ function keyalt() {
|
|
|
105
106
|
else {
|
|
106
107
|
root_menu.tabIndex = 0;
|
|
107
108
|
root_menu.focus();
|
|
109
|
+
root_menu.setFocus(this.firstMenu);
|
|
108
110
|
}
|
|
109
|
-
|
|
111
|
+
}
|
|
112
|
+
function keytab(event) {
|
|
113
|
+
if (root_menu !== document.activeElement) return;
|
|
114
|
+
var menu = mounted_menus[mounted_menus.length - 1] || root_menu;
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
menu.moveFocus(1);
|
|
110
117
|
}
|
|
111
118
|
function keyesc() {
|
|
112
119
|
if (root_menu === document.activeElement && !mounted_menus.length) {
|
|
113
|
-
if (!root_menu.ispop) root_menu.blur()
|
|
120
|
+
if (!root_menu.ispop) root_menu.blur();
|
|
114
121
|
else root_menu.ispop = false;
|
|
115
122
|
}
|
|
116
123
|
}
|
|
@@ -128,11 +135,15 @@ function keyright() {
|
|
|
128
135
|
}
|
|
129
136
|
function keyspace() {
|
|
130
137
|
if (root_menu !== document.activeElement) return;
|
|
131
|
-
var menu = mounted_menus[mounted_menus.length - 1]
|
|
132
|
-
menu.focused.
|
|
138
|
+
var menu = mounted_menus[mounted_menus.length - 1];
|
|
139
|
+
if (!menu || !menu.focused) menu = mounted_menus[mounted_menus.length - 2] || root_menu;
|
|
140
|
+
if (menu.focused) {
|
|
141
|
+
menu.focused.click();
|
|
142
|
+
}
|
|
133
143
|
}
|
|
134
144
|
function register() {
|
|
135
145
|
// on('keydown.alt')(window, e => e.preventDefault());
|
|
146
|
+
on('keydown.tab')(window, keytab);
|
|
136
147
|
on('keydown.alt.')(window, keyalt);
|
|
137
148
|
on('keydown.esc')(window, keyesc);
|
|
138
149
|
on('keydown.left')(window, keyleft);
|
|
@@ -150,19 +161,20 @@ function main(page, items, active, direction = 'y') {
|
|
|
150
161
|
var main = this;
|
|
151
162
|
if (direction !== 'x') page.ispop = true;
|
|
152
163
|
function popMenu(item, target) {
|
|
153
|
-
if (page.
|
|
164
|
+
if (page.actived) {
|
|
154
165
|
clear();
|
|
155
|
-
remove(page.
|
|
166
|
+
remove(page.actived);
|
|
156
167
|
}
|
|
157
168
|
page.setFocus(target);
|
|
158
169
|
if (!item.children || !item.children.length) return;
|
|
159
170
|
var clone = template.cloneNode();
|
|
160
171
|
clone.$parentScopes = page.$parentScopes;
|
|
172
|
+
clone.$scope = page.$scope;
|
|
161
173
|
clone.$src = src;
|
|
162
174
|
clone.innerHTML = template.innerHTML;
|
|
163
175
|
var menu = main(clone, item.children, active);
|
|
164
176
|
mounted_menus.push(menu);
|
|
165
|
-
page.
|
|
177
|
+
page.actived = menu;
|
|
166
178
|
menu.root = page.root || page;
|
|
167
179
|
popup(menu, target);
|
|
168
180
|
if (page.ispop === true) {
|
|
@@ -206,21 +218,26 @@ function main(page, items, active, direction = 'y') {
|
|
|
206
218
|
}
|
|
207
219
|
var fire = function () {
|
|
208
220
|
cancel();
|
|
221
|
+
if (this.menu.line) return;
|
|
209
222
|
var pop = active(this.menu, this);
|
|
210
223
|
if (pop === false) return;
|
|
211
224
|
var root = page.root || page;
|
|
212
225
|
if (root.ispop === 1) root.ispop = false;
|
|
213
|
-
if (page.
|
|
226
|
+
if (page.actived && page.actived.target === this) {
|
|
227
|
+
while (mounted_menus.length && mounted_menus[mounted_menus.length - 1] !== page.actived) remove(mounted_menus.pop());
|
|
214
228
|
if (!mounted_menus.length) {
|
|
215
229
|
popMenu(this.menu, this);
|
|
216
230
|
}
|
|
217
231
|
else {
|
|
218
|
-
|
|
232
|
+
remove(mounted_menus.pop());
|
|
219
233
|
}
|
|
220
234
|
}
|
|
221
235
|
else {
|
|
222
236
|
while (mounted_menus.length && mounted_menus[mounted_menus.length - 1] !== page) remove(mounted_menus.pop());
|
|
223
237
|
popMenu(this.menu, this);
|
|
238
|
+
if (!page.actived) {
|
|
239
|
+
(page.root || page).blur();
|
|
240
|
+
}
|
|
224
241
|
}
|
|
225
242
|
};
|
|
226
243
|
|
|
@@ -237,8 +254,8 @@ function main(page, items, active, direction = 'y') {
|
|
|
237
254
|
return false;
|
|
238
255
|
};
|
|
239
256
|
var $scope = {
|
|
240
|
-
"menu-item"
|
|
241
|
-
var a =
|
|
257
|
+
"menu-item"(e, s) {
|
|
258
|
+
var a = button(
|
|
242
259
|
menuItem(e, s, this.hasIcon)
|
|
243
260
|
);
|
|
244
261
|
if (!page.firstMenu) {
|
|
@@ -254,31 +271,23 @@ function main(page, items, active, direction = 'y') {
|
|
|
254
271
|
};
|
|
255
272
|
if (page.$src) {
|
|
256
273
|
var src = page.$src;
|
|
257
|
-
var parentScopes = page.$parentScopes;
|
|
258
274
|
var itemName = src.itemName;
|
|
259
275
|
var className = `{'has-children':${itemName}.children&&${itemName}.children.length,'warn':${itemName}.type==='danger'||${itemName}.type==='warn'||${itemName}.type==='red'}`;
|
|
260
276
|
var notHidden = `!${itemName}.hidden`;
|
|
277
|
+
var generator = getGenerator(page, 'menu-item');
|
|
261
278
|
|
|
262
279
|
list(page, function (index) {
|
|
263
280
|
var item = items[index];
|
|
264
281
|
if (!item) return;
|
|
265
|
-
var a = $scope["menu-item"](null, item);
|
|
266
|
-
var scope = {};
|
|
267
282
|
if (item instanceof Item) item = item.value;
|
|
268
|
-
|
|
269
|
-
else scope.$item = item;
|
|
270
|
-
if (src.keyName) scope[src.keyName] = index;
|
|
271
|
-
else scope.$key = index;
|
|
272
|
-
if (src.indexName) scope[src.indexName] = index;
|
|
273
|
-
else scope.$index = index;
|
|
274
|
-
if (src.srcName) scope[src.srcName] = items;
|
|
283
|
+
var a = $scope["menu-item"](null, item);
|
|
275
284
|
if (src.itemName) a.setAttribute("e-if", notHidden);
|
|
285
|
+
a.setAttribute("e-class", className);
|
|
286
|
+
a = generator(index, item, a);
|
|
276
287
|
a.menu = item;
|
|
277
288
|
on("mouseleave")(a, cancel);
|
|
278
289
|
on("mouseenter")(a, open);
|
|
279
290
|
on("click")(a, fire);
|
|
280
|
-
a.setAttribute("e-class", className);
|
|
281
|
-
render(a, scope, parentScopes);
|
|
282
291
|
return a;
|
|
283
292
|
});
|
|
284
293
|
on("append")(page, function () {
|
|
@@ -296,7 +305,7 @@ function main(page, items, active, direction = 'y') {
|
|
|
296
305
|
});
|
|
297
306
|
}
|
|
298
307
|
else {
|
|
299
|
-
var generator = getGenerator(page);
|
|
308
|
+
var generator = getGenerator(page, 'menu-item');
|
|
300
309
|
|
|
301
310
|
list(page, function (index) {
|
|
302
311
|
var elem = generator(index);
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
background-color: #fff;
|
|
6
6
|
box-shadow: 0 0 20px -6px rgba(0, 0, 0, .1);
|
|
7
7
|
border: 1px solid #0003;
|
|
8
|
-
line-height: 28px;
|
|
9
8
|
padding: 6px 0;
|
|
10
9
|
|
|
11
10
|
>menu-item {
|
|
@@ -17,6 +16,10 @@
|
|
|
17
16
|
color: inherit;
|
|
18
17
|
box-shadow: none;
|
|
19
18
|
text-align: inherit;
|
|
19
|
+
vertical-align: top;
|
|
20
|
+
line-height: 20px;
|
|
21
|
+
padding-top: 4px;
|
|
22
|
+
padding-bottom: 4px;
|
|
20
23
|
|
|
21
24
|
&.warn {
|
|
22
25
|
color: #c28;
|
|
@@ -27,7 +30,8 @@
|
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
&.has-children {
|
|
30
|
-
padding:
|
|
33
|
+
padding-right: 24px;
|
|
34
|
+
padding-left: 16px;
|
|
31
35
|
|
|
32
36
|
&:after {
|
|
33
37
|
content: ">";
|