efront 3.25.8 → 3.25.12
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/coms/basic/Item.js +15 -1
- package/coms/basic/Matrix.js +9 -1
- package/coms/basic/Speed.js +46 -15
- package/coms/basic/awaitable.js +41 -0
- package/coms/{zimoli → basic}/cancelAnimationFrame.js +1 -0
- package/coms/basic/lazy.js +29 -12
- package/coms/basic/loader.js +1 -1
- 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 +5 -2
- package/coms/zimoli/attr.js +9 -3
- package/coms/zimoli/bindAccesskey.js +18 -8
- package/coms/zimoli/button.js +3 -2
- package/coms/zimoli/getGenerator.js +24 -8
- package/coms/zimoli/getName.js +7 -5
- package/coms/zimoli/innerHeight.js +2 -1
- package/coms/zimoli/innerWidth.js +2 -1
- package/coms/zimoli/list.js +141 -12
- package/coms/zimoli/menu.js +8 -4
- package/coms/zimoli/menuItem.html +5 -3
- package/coms/zimoli/menuItem.js +2 -2
- package/coms/zimoli/menuItem.less +2 -1
- package/coms/zimoli/menuList.js +203 -203
- package/coms/zimoli/menuList.less +1 -0
- package/coms/zimoli/on.js +61 -17
- package/coms/zimoli/onmouseleave.js +1 -1
- package/coms/zimoli/onmousewheel.js +1 -1
- package/coms/zimoli/picture_.js +4 -2
- package/coms/zimoli/popup.js +18 -22
- package/coms/zimoli/render.js +6 -4
- package/coms/zimoli/slider.js +6 -3
- package/coms/zimoli/slider_test.js +1 -1
- package/coms/zimoli/table.js +1 -0
- package/coms/zimoli/vbox.js +14 -7
- 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/coms/zimoli/menuList.js
CHANGED
|
@@ -9,50 +9,20 @@ var release = function () {
|
|
|
9
9
|
var clear = function () {
|
|
10
10
|
clearTimeout(releaseTimer);
|
|
11
11
|
};
|
|
12
|
-
var unfocus = function () {
|
|
12
|
+
var unfocus = lazy(function () {
|
|
13
|
+
if (mounted_menus.indexOf(document.activeElement) >= 0) return;
|
|
13
14
|
remove(mounted_menus);
|
|
14
|
-
|
|
15
|
-
this.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
page.focused = focused;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
if (page.focused) {
|
|
29
|
-
removeClass(page.focused, 'focus');
|
|
30
|
-
page.focused = null;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
var moveFocus = function (delta) {
|
|
35
|
-
var page = this;
|
|
36
|
-
var focused = page.focused;
|
|
37
|
-
var newIndex = 0;
|
|
38
|
-
if (!focused) {
|
|
39
|
-
if (delta > 0) newIndex = 0;
|
|
40
|
-
else newIndex = page.total - 1;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
var newIndex = focused.index + delta;
|
|
44
|
-
var total = page.total;
|
|
45
|
-
if (newIndex < 0) newIndex = total + newIndex;
|
|
46
|
-
if (newIndex > total - 1) newIndex = newIndex - total;
|
|
15
|
+
if (root_menu) root_menu.setFocus(null);
|
|
16
|
+
var root = this.root || this;
|
|
17
|
+
if (root.ispop === 1) root.ispop = false;
|
|
18
|
+
root.actived = null;
|
|
19
|
+
root.setFocus(null);
|
|
20
|
+
});
|
|
21
|
+
var unblur = function () {
|
|
22
|
+
if (document.activeElement !== this) {
|
|
23
|
+
this.tabIndex = 0;
|
|
24
|
+
this.focus();
|
|
47
25
|
}
|
|
48
|
-
do {
|
|
49
|
-
var e = page.getIndexedElement(newIndex);
|
|
50
|
-
if (newIndex < 0) newIndex = total + newIndex;
|
|
51
|
-
newIndex += delta;
|
|
52
|
-
} while (e && (e.hasAttribute("disabled") || e.hasAttribute("line")));
|
|
53
|
-
if (!e) page.setFocus(null);
|
|
54
|
-
else if (page.ispop !== true) page.setFocus(e), page.open(e);
|
|
55
|
-
else page.setFocus(e);
|
|
56
26
|
};
|
|
57
27
|
var openFocus = function () {
|
|
58
28
|
var menu = mounted_menus[mounted_menus.length - 1] || root_menu;
|
|
@@ -76,19 +46,24 @@ var keyAction = function (deltax, deltay) {
|
|
|
76
46
|
if (fmenu && fmenu.children && fmenu.children.length) {
|
|
77
47
|
openFocus();
|
|
78
48
|
}
|
|
79
|
-
else if (parent
|
|
80
|
-
|
|
49
|
+
else if (parent) {
|
|
50
|
+
var index = mounted_menus.lastIndexOf(parent);
|
|
51
|
+
while (parent && parent.direction === 'y') {
|
|
52
|
+
parent = mounted_menus[--index];
|
|
53
|
+
}
|
|
54
|
+
if (!parent && root_menu.direction !== 'y') parent = root_menu;
|
|
55
|
+
if (parent) parent.moveFocus(deltax, parent.ispop);
|
|
81
56
|
}
|
|
82
57
|
}
|
|
83
58
|
else if (deltax === -1) {
|
|
84
59
|
// left
|
|
85
60
|
if (parent) {
|
|
86
61
|
if (parent.direction === 'y') remove(mounted_menus.pop());
|
|
87
|
-
else parent.moveFocus(deltax);
|
|
62
|
+
else parent.moveFocus(deltax, parent.ispop);
|
|
88
63
|
}
|
|
89
64
|
}
|
|
90
65
|
else {
|
|
91
|
-
menu.moveFocus(deltay);
|
|
66
|
+
menu.moveFocus(deltay, menu.ispop);
|
|
92
67
|
}
|
|
93
68
|
}
|
|
94
69
|
else {
|
|
@@ -96,19 +71,24 @@ var keyAction = function (deltax, deltay) {
|
|
|
96
71
|
// down
|
|
97
72
|
if (menu.focused) var fmenu = menu.focused.menu;
|
|
98
73
|
if (fmenu && fmenu.children && fmenu.children.length) openFocus();
|
|
99
|
-
else if (parent
|
|
100
|
-
|
|
74
|
+
else if (parent) {
|
|
75
|
+
var index = mounted_menus.lastIndexOf(parent);
|
|
76
|
+
while (parent && parent.direction !== 'y') {
|
|
77
|
+
parent = mounted_menus[--index];
|
|
78
|
+
}
|
|
79
|
+
if (!parent && root_menu.direction === 'y') parent = root_menu;
|
|
80
|
+
if (parent) parent.moveFocus(deltay, parent.ispop);
|
|
101
81
|
}
|
|
102
82
|
}
|
|
103
83
|
else if (deltay === -1) {
|
|
104
84
|
// up
|
|
105
85
|
if (parent) {
|
|
106
86
|
if (parent.direction !== 'y') remove(mounted_menus.pop());
|
|
107
|
-
else parent.moveFocus(deltay);
|
|
87
|
+
else parent.moveFocus(deltay, parent.ispop);
|
|
108
88
|
}
|
|
109
89
|
}
|
|
110
90
|
else {
|
|
111
|
-
menu.moveFocus(deltax);
|
|
91
|
+
menu.moveFocus(deltax, menu.ispop);
|
|
112
92
|
}
|
|
113
93
|
}
|
|
114
94
|
};
|
|
@@ -117,7 +97,7 @@ function keyalt() {
|
|
|
117
97
|
else if (root_menu === this && root_menu !== document.activeElement) {
|
|
118
98
|
root_menu.tabIndex = 0;
|
|
119
99
|
root_menu.focus();
|
|
120
|
-
root_menu.setFocus(root_menu.
|
|
100
|
+
root_menu.setFocus(root_menu.getIndexedElement(0));
|
|
121
101
|
}
|
|
122
102
|
}
|
|
123
103
|
function keytab(event) {
|
|
@@ -144,26 +124,49 @@ function keyleft() {
|
|
|
144
124
|
function keyright() {
|
|
145
125
|
keyAction(1, 0);
|
|
146
126
|
}
|
|
147
|
-
function
|
|
127
|
+
function getFocusedMenu() {
|
|
148
128
|
var menu = mounted_menus[mounted_menus.length - 1];
|
|
149
129
|
if (!menu || !menu.focused) menu = mounted_menus[mounted_menus.length - 2] || root_menu;
|
|
150
|
-
if (
|
|
130
|
+
if (mounted_menus.indexOf(document.activeElement) >= 0 || document.activeElement === root_menu) return menu;
|
|
131
|
+
}
|
|
132
|
+
function keyspace() {
|
|
133
|
+
var menu = getFocusedMenu();
|
|
134
|
+
if (menu && menu.focused) {
|
|
151
135
|
menu.focused.click();
|
|
152
136
|
}
|
|
153
137
|
}
|
|
138
|
+
function keyhome() {
|
|
139
|
+
var menu = getFocusedMenu();
|
|
140
|
+
if (menu) menu.moveFocus("home", true);
|
|
141
|
+
}
|
|
142
|
+
function keyend() {
|
|
143
|
+
var menu = getFocusedMenu();
|
|
144
|
+
if (menu) menu.moveFocus("end", true);
|
|
145
|
+
}
|
|
146
|
+
function keypagedown() {
|
|
147
|
+
var menu = getFocusedMenu();
|
|
148
|
+
if (menu) menu.moveFocus("pagedown", true);
|
|
149
|
+
}
|
|
150
|
+
function keypageup() {
|
|
151
|
+
var menu = getFocusedMenu();
|
|
152
|
+
if (menu) menu.moveFocus("pageup", true);
|
|
153
|
+
}
|
|
154
154
|
function register() {
|
|
155
155
|
var menu = this;
|
|
156
156
|
// if (!root_menu) root_menu = this;
|
|
157
|
-
bind('keydown.alt.')(menu, keyalt);
|
|
158
|
-
bind('keydown.esc')(menu, keyesc);
|
|
159
|
-
on('keydown.
|
|
160
|
-
on('keydown.
|
|
161
|
-
on('keydown.
|
|
162
|
-
on('keydown.
|
|
163
|
-
on('keydown.
|
|
164
|
-
on('keydown.
|
|
165
|
-
on('keydown.
|
|
166
|
-
on(
|
|
157
|
+
bind('keydown.only.alt.')(menu, keyalt);
|
|
158
|
+
bind('keydown.esc.only')(menu, keyesc);
|
|
159
|
+
on('keydown.pageup.only')(menu, keypageup);
|
|
160
|
+
on('keydown.pagedown.only')(menu, keypagedown);
|
|
161
|
+
on('keydown.home.only')(menu, keyhome);
|
|
162
|
+
on('keydown.end.only')(menu, keyend);
|
|
163
|
+
on('keydown.tab.only')(menu, keytab);
|
|
164
|
+
on('keydown.left.only')(menu, keyleft);
|
|
165
|
+
on('keydown.right.only')(menu, keyright);
|
|
166
|
+
on('keydown.up.only')(menu, keyup);
|
|
167
|
+
on('keydown.down.only')(menu, keydown);
|
|
168
|
+
on('keydown.enter.only')(menu, keyspace);
|
|
169
|
+
on('keydown.space.only')(menu, keyspace);
|
|
167
170
|
}
|
|
168
171
|
function main() {
|
|
169
172
|
var page, items, active = _active, direction = 'y';
|
|
@@ -179,70 +182,64 @@ function main() {
|
|
|
179
182
|
var main = this;
|
|
180
183
|
if (direction == 'y') page.ispop = true;
|
|
181
184
|
var istoolbar = direction === 't';
|
|
182
|
-
function popMenu(item, target
|
|
185
|
+
function popMenu(item, target) {
|
|
183
186
|
if (page.actived) {
|
|
184
187
|
clear();
|
|
185
188
|
remove(page.actived);
|
|
186
189
|
}
|
|
187
|
-
if (emptyFocus !== false) page.setFocus(target);
|
|
188
190
|
if (!item.length) return;
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
191
|
+
var menu = item.menu;
|
|
192
|
+
if (!menu) {
|
|
193
|
+
var clone = template.cloneNode();
|
|
194
|
+
clone.$parentScopes = page.$parentScopes;
|
|
195
|
+
clone.$scope = page.$scope;
|
|
196
|
+
clone.$src = src;
|
|
197
|
+
clone.innerHTML = template.innerHTML;
|
|
198
|
+
menu = item.menu = main(clone, item.children, active);
|
|
199
|
+
}
|
|
196
200
|
mounted_menus.push(menu);
|
|
197
201
|
page.actived = menu;
|
|
198
202
|
menu.root = page.root || page;
|
|
199
|
-
menu.go(0);
|
|
203
|
+
if (menu.go) menu.go(0);
|
|
200
204
|
popup(menu, target);
|
|
201
205
|
if (page.ispop === true) {
|
|
202
206
|
} else {
|
|
203
207
|
page.ispop = 1;
|
|
204
|
-
page.tabIndex = 0;
|
|
205
|
-
page.focus();
|
|
206
208
|
}
|
|
207
|
-
on("
|
|
208
|
-
once("remove")(menu, function () {
|
|
209
|
+
on("remove")(menu, function () {
|
|
209
210
|
removeFromList(mounted_menus, this);
|
|
211
|
+
menu.setFocus(null);
|
|
212
|
+
css(menu, "width:;height:;max-height:;max-width:;");
|
|
210
213
|
});
|
|
214
|
+
return menu;
|
|
211
215
|
}
|
|
212
216
|
on("blur")(page, unfocus);
|
|
213
|
-
var template = page
|
|
214
|
-
if (!page
|
|
217
|
+
var template = page.$template || document.createElement(page.tagName);
|
|
218
|
+
if (!page.$template) {
|
|
215
219
|
template.className = '';
|
|
216
220
|
template.removeAttribute('mode');
|
|
217
221
|
template.innerHTML = page.innerHTML;
|
|
218
|
-
page
|
|
222
|
+
page.$template = template;
|
|
219
223
|
}
|
|
220
|
-
var
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
page.setFocus(elem);
|
|
230
|
-
popMenu(elem.menu, elem);
|
|
231
|
-
}, time || 60);
|
|
224
|
+
var enterMenu = lazy(function (menu) {
|
|
225
|
+
if (page.ispop) {
|
|
226
|
+
page.setFocus(menu);
|
|
227
|
+
popMenu(menu.menu, menu);
|
|
228
|
+
}
|
|
229
|
+
}, 60);
|
|
230
|
+
on('pointerdown')(page, unblur);
|
|
231
|
+
var autoremove = function () {
|
|
232
|
+
document.activeElement.blur();
|
|
232
233
|
};
|
|
233
|
-
var
|
|
234
|
-
clear();
|
|
235
|
-
clearTimeout(popTimer);
|
|
236
|
-
}
|
|
237
|
-
var fire = async function () {
|
|
238
|
-
cancel();
|
|
234
|
+
var activeMenu = function () {
|
|
239
235
|
if (this.menu.line) return;
|
|
240
|
-
if (byMousedown) return;
|
|
241
236
|
if (this.hasAttribute("disabled") || this.hasAttribute('line')) return;
|
|
242
237
|
var pop = active(this.menu.value, this);
|
|
243
238
|
if (pop === false) return;
|
|
244
239
|
var root = page.root || page;
|
|
245
|
-
|
|
240
|
+
var istool = root.direction === 't' || root.selected
|
|
241
|
+
if (root.ispop === 1) root.ispop = false;
|
|
242
|
+
if (istool) {
|
|
246
243
|
var menu = this.menu;
|
|
247
244
|
if (root.selected) root.selected.setActive(false);
|
|
248
245
|
if (root !== page) {
|
|
@@ -256,138 +253,141 @@ function main() {
|
|
|
256
253
|
}
|
|
257
254
|
menu.setActive(true);
|
|
258
255
|
root.selected = target.menu;
|
|
256
|
+
autoremove();
|
|
257
|
+
return;
|
|
259
258
|
}
|
|
260
|
-
if (root.ispop === 1) root.ispop = false;
|
|
261
259
|
if (page.actived && page.actived.target === this) {
|
|
262
|
-
while (mounted_menus.length && mounted_menus[mounted_menus.length - 1] !== page.actived) remove(mounted_menus.pop());
|
|
263
|
-
if (!mounted_menus.length) {
|
|
264
|
-
if (byMousedown === false) return;
|
|
260
|
+
if (mounted_menus.indexOf(page.actived) >= 0) while (mounted_menus.length && mounted_menus[mounted_menus.length - 1] !== page.actived) remove(mounted_menus.pop());
|
|
261
|
+
if (!mounted_menus.length || page === mounted_menus[mounted_menus.length - 1]) {
|
|
265
262
|
popMenu(this.menu, this, false);
|
|
266
263
|
}
|
|
267
264
|
else {
|
|
268
265
|
remove(mounted_menus.pop());
|
|
266
|
+
page.actived = null;
|
|
269
267
|
}
|
|
270
268
|
}
|
|
271
269
|
else {
|
|
272
270
|
while (mounted_menus.length && mounted_menus[mounted_menus.length - 1] !== page) remove(mounted_menus.pop());
|
|
273
|
-
|
|
271
|
+
page.actived = null;
|
|
274
272
|
popMenu(this.menu, this, false);
|
|
275
273
|
if (!page.actived) {
|
|
276
|
-
(
|
|
274
|
+
autoremove();
|
|
277
275
|
}
|
|
278
276
|
}
|
|
279
277
|
};
|
|
280
|
-
var
|
|
281
|
-
if (event.which === 3)
|
|
282
|
-
|
|
278
|
+
var pressMenu = function (event) {
|
|
279
|
+
if (event.which === 3) {
|
|
280
|
+
popMenu(this.menu, this);
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
switchMenu.done = false;
|
|
284
|
+
switchMenu.call(this);
|
|
285
|
+
}
|
|
283
286
|
};
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
287
|
+
var clickMenu = function (event) {
|
|
288
|
+
switchMenu.cancel();
|
|
289
|
+
if (!switchMenu.done) page.setFocus(this), activeMenu.call(this);
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
var switchMenu = lazy(function (event) {
|
|
294
|
+
if (onclick.preventClick) return;
|
|
295
|
+
popMenu(this.menu, this);
|
|
296
|
+
switchMenu.done = true;
|
|
297
|
+
}, 300);
|
|
298
|
+
var hasIcon = function () {
|
|
299
|
+
var menus = items;
|
|
300
|
+
for (var menu of menus) {
|
|
301
|
+
if (menu.icon) {
|
|
302
|
+
return true;
|
|
292
303
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
)
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
if (page.$src) {
|
|
315
|
-
var src = page.$src;
|
|
316
|
-
var itemName = src.itemName;
|
|
317
|
-
var className = `{'has-children':${itemName}.children&&${itemName}.children.length,
|
|
304
|
+
}
|
|
305
|
+
return false;
|
|
306
|
+
};
|
|
307
|
+
var $scope = {
|
|
308
|
+
"menu-item"(e, s) {
|
|
309
|
+
if (e && s === e.$scope) s = itemName ? s[itemName] : s.menu;
|
|
310
|
+
var a = button(
|
|
311
|
+
menuItem(e, s, this.hasIcon)
|
|
312
|
+
);
|
|
313
|
+
a.menu = s;
|
|
314
|
+
return a;
|
|
315
|
+
},
|
|
316
|
+
hasIcon: hasIcon(),
|
|
317
|
+
enterMenu,
|
|
318
|
+
clickMenu,
|
|
319
|
+
pressMenu,
|
|
320
|
+
};
|
|
321
|
+
if (!page.$src) page.$src = render.parseRepeat("m in menus");
|
|
322
|
+
var src = page.$src;
|
|
323
|
+
var itemName = src.itemName;
|
|
324
|
+
var className = `{'has-children':${itemName}.children&&${itemName}.children.length,
|
|
318
325
|
'warn':${itemName}.warn,
|
|
319
326
|
actived:${itemName}.isActived()
|
|
320
327
|
}`;
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
a = generator(index, item, a);
|
|
342
|
-
return a;
|
|
343
|
-
}, direction);
|
|
344
|
-
}
|
|
345
|
-
else {
|
|
346
|
-
page.innerHTML = menuList;
|
|
347
|
-
$scope.menus = items.map(i => i.constructor === Item ? i : new Item(i));
|
|
348
|
-
render(page, $scope);
|
|
349
|
-
vbox(page);
|
|
350
|
-
}
|
|
351
|
-
page.total = items.length;
|
|
352
|
-
page.renders.unshift(function () {
|
|
353
|
-
this.$scope.hasIcon = hasIcon();
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
else {
|
|
357
|
-
var generator = getGenerator(page, 'menu-item');
|
|
358
|
-
list(page, function (index) {
|
|
359
|
-
var elem = generator(index);
|
|
360
|
-
if (!elem) return;
|
|
361
|
-
if (!page.firstMenu) {
|
|
362
|
-
page.firstMenu = elem;
|
|
363
|
-
page.total = this.src.length;
|
|
328
|
+
var notHidden = `!${itemName}.hidden`;
|
|
329
|
+
var ItemTemplate = document.createElement('menu-item');
|
|
330
|
+
ItemTemplate.setAttribute("on-click", "clickMenu.call(this,event)");
|
|
331
|
+
if (istoolbar) ItemTemplate.setAttribute("on-pointerdown", "pressMenu.call(this,event)");
|
|
332
|
+
else ItemTemplate.setAttribute("on-mouseenter", `enterMenu(this)`);
|
|
333
|
+
ItemTemplate.setAttribute("e-class", className);
|
|
334
|
+
if (src.itemName) ItemTemplate.setAttribute("e-if", notHidden);
|
|
335
|
+
ItemTemplate.setAttribute("_menu", src.itemName);
|
|
336
|
+
ItemTemplate.innerHTML = menuItem.template;
|
|
337
|
+
var generator = getGenerator(page, ItemTemplate);
|
|
338
|
+
page.$generatorScopes.push($scope);
|
|
339
|
+
list(page, function (index) {
|
|
340
|
+
var item = items[index];
|
|
341
|
+
if (!item) return;
|
|
342
|
+
if (item.constructor !== Item) item = new Item(item);
|
|
343
|
+
if (istoolbar) {
|
|
344
|
+
if (item.constructor === Item && item.length && !item.extended) {
|
|
345
|
+
item.extends(item[0]);
|
|
364
346
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
menu.extends(menu[0]);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
on("click")(elem, fire);
|
|
375
|
-
return elem;
|
|
376
|
-
}, direction);
|
|
377
|
-
}
|
|
347
|
+
}
|
|
348
|
+
return generator(index, item);
|
|
349
|
+
}, direction);
|
|
350
|
+
page.renders.unshift(function () {
|
|
351
|
+
this.$scope.hasIcon = hasIcon();
|
|
352
|
+
});
|
|
378
353
|
page.open = function (a) {
|
|
379
|
-
|
|
354
|
+
if (!a.menu || !a.menu.length) {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
var m = popMenu(a.menu, a);
|
|
358
|
+
m.moveFocus("home");
|
|
380
359
|
};
|
|
381
360
|
page.active = function (a) {
|
|
382
|
-
|
|
361
|
+
activeMenu.call(a);
|
|
383
362
|
};
|
|
384
|
-
page
|
|
385
|
-
|
|
363
|
+
if (istoolbar) on("active")(page, function (event) {
|
|
364
|
+
if (event.item !== 'global') return;
|
|
365
|
+
if (page.selected) page.selected.setActive(false);
|
|
366
|
+
var selected = null;
|
|
367
|
+
for (var e of this.children) {
|
|
368
|
+
if (!e.menu) continue;
|
|
369
|
+
selected = e.menu.pathTo(event.value);
|
|
370
|
+
if (selected) break;
|
|
371
|
+
}
|
|
372
|
+
if (!selected) return;
|
|
373
|
+
var menu = selected.pop();
|
|
374
|
+
page.selected = menu;
|
|
375
|
+
if (selected[0]) selected[0].extends(menu.value);
|
|
376
|
+
menu.setActive(true);
|
|
377
|
+
});
|
|
378
|
+
on("focused")(page, function () {
|
|
379
|
+
var focused = page.focused;
|
|
380
|
+
if (page.ispop && page === root_menu) popMenu(focused.menu, focused, false);
|
|
381
|
+
});
|
|
386
382
|
page.openFocus = openFocus;
|
|
387
383
|
page.closeFocus = closeFocus;
|
|
388
384
|
page.direction = direction;
|
|
389
|
-
|
|
385
|
+
on("contextmenu")(page, e => e.preventDefault());
|
|
386
|
+
on("mouseleave")(page, function () {
|
|
387
|
+
enterMenu.cancel();
|
|
388
|
+
});
|
|
390
389
|
page.registerAsRoot = function () {
|
|
390
|
+
register.call(this);
|
|
391
391
|
root_menu = this;
|
|
392
392
|
};
|
|
393
393
|
return page;
|