efront 3.10.5 → 3.11.2
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/pivot/api.yml +1 -0
- package/apps/pivot/home/welcome.html +6 -1
- package/apps/pivot/home/welcome.js +2 -0
- package/coms/frame/route.js +0 -1
- package/coms/zimoli/active.js +5 -1
- package/coms/zimoli/bindAccesskey.js +47 -0
- package/coms/zimoli/button.js +0 -34
- package/coms/zimoli/data.js +2 -1
- package/coms/zimoli/menu.js +8 -4
- package/coms/zimoli/menu.less +12 -5
- package/coms/zimoli/menuItem.html +2 -2
- package/coms/zimoli/menuItem.js +7 -3
- package/coms/zimoli/menuList.html +2 -2
- package/coms/zimoli/menuList.js +278 -42
- package/coms/zimoli/menuList.less +6 -1
- package/coms/zimoli/on.js +14 -3
- package/coms/zimoli/render.js +39 -13
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/apps/pivot/api.yml
CHANGED
package/coms/frame/route.js
CHANGED
package/coms/zimoli/active.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
// 激活 自定义的 active 事件
|
|
2
|
-
function active(target, value, item) {
|
|
2
|
+
function active(target, value, item, targetElement) {
|
|
3
3
|
var activeEvent = createEvent("active");
|
|
4
4
|
activeEvent.item = item;
|
|
5
5
|
activeEvent.value = value;
|
|
6
|
+
if (targetElement) {
|
|
7
|
+
if (Object.defineProperty) Object.defineProperty(activeEvent, 'currentTarget', { value: targetElement });
|
|
8
|
+
else activeEvent.currentTarget = targetElement;
|
|
9
|
+
}
|
|
6
10
|
activeEvent = dispatch(target, activeEvent);
|
|
7
11
|
return activeEvent && !activeEvent.defaultPrevented;
|
|
8
12
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var keyMap = {};
|
|
2
|
+
on("keydown")(window, function (event) {
|
|
3
|
+
var { which } = event;
|
|
4
|
+
switch (event.which) {
|
|
5
|
+
case 18:
|
|
6
|
+
event.preventDefault();
|
|
7
|
+
break;
|
|
8
|
+
default:
|
|
9
|
+
var key = String.fromCharCode(which);
|
|
10
|
+
var elems = keyMap[key];
|
|
11
|
+
if (elems) while (elems.length) {
|
|
12
|
+
var elem = elems[elems.length - 1];
|
|
13
|
+
if (isMounted(elem)) break;
|
|
14
|
+
else elems.pop();
|
|
15
|
+
}
|
|
16
|
+
if (elem) {
|
|
17
|
+
var parent = elem.parentNode;
|
|
18
|
+
if (event.altKey || parent === document.activeElement || parent.ispop) {
|
|
19
|
+
event.preventDefault();
|
|
20
|
+
elem.click();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
var bindAccesskey = function (btn, k) {
|
|
26
|
+
if (!keyMap[k]) keyMap[k] = [];
|
|
27
|
+
removeFromList(keyMap[k], btn);
|
|
28
|
+
keyMap[k].push(btn);
|
|
29
|
+
once("remove")(btn, function () {
|
|
30
|
+
removeFromList(keyMap[k], btn);
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
var getKeyFromText = function (btn) {
|
|
34
|
+
var { innerText } = btn;
|
|
35
|
+
var match = /\(\s*\_?\w\s*\)|\[\s*\_?\w\s*\]|\{\s*\_?\w\s*\}/.exec(innerText);
|
|
36
|
+
if (match) {
|
|
37
|
+
var accesskey = match[0].replace(/^\W*(\w)\W*$/g, '$1');
|
|
38
|
+
} else {
|
|
39
|
+
var accesskey = btn.getAttribute("accesskey");
|
|
40
|
+
}
|
|
41
|
+
if (!accesskey) return;
|
|
42
|
+
return accesskey.toUpperCase();
|
|
43
|
+
}
|
|
44
|
+
function main(elem, key = getKeyFromText(elem)) {
|
|
45
|
+
bindAccesskey(elem, key);
|
|
46
|
+
return elem;
|
|
47
|
+
}
|
package/coms/zimoli/button.js
CHANGED
|
@@ -2,29 +2,6 @@ var _label = createElement("span");
|
|
|
2
2
|
var track = createElement(div);
|
|
3
3
|
track.className = "track";
|
|
4
4
|
_label.className = "label";
|
|
5
|
-
var keyMap = {};
|
|
6
|
-
on("keydown")(window, function (event) {
|
|
7
|
-
var { which } = event;
|
|
8
|
-
switch (event.which) {
|
|
9
|
-
case 18:
|
|
10
|
-
event.preventDefault();
|
|
11
|
-
break;
|
|
12
|
-
default:
|
|
13
|
-
if (event.altKey) {
|
|
14
|
-
var key = String.fromCharCode(which);
|
|
15
|
-
var element = keyMap[key];
|
|
16
|
-
|
|
17
|
-
if (element) {
|
|
18
|
-
if (isMounted(element)) {
|
|
19
|
-
dispatch(window, 'mousedown');
|
|
20
|
-
element.click();
|
|
21
|
-
} else {
|
|
22
|
-
delete keyMap[key];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
5
|
|
|
29
6
|
var btn = document.createElement("button");
|
|
30
7
|
btn.tabIndex = 0;
|
|
@@ -76,17 +53,6 @@ var touchstart = function () {
|
|
|
76
53
|
var canceltouchend = ontouchend(this, cancel);
|
|
77
54
|
active.call(this);
|
|
78
55
|
};
|
|
79
|
-
var bindAccesskey = function (btn) {
|
|
80
|
-
var { innerText } = btn;
|
|
81
|
-
var match = /\(\s*\_?\w\s*\)|\[\s*\_?\w\s*\]|\{\s*\_?\w\s*\}/.exec(innerText);
|
|
82
|
-
if (match) {
|
|
83
|
-
var accesskey = match[0].replace(/^\W*(\w)\W*$/g, '$1');
|
|
84
|
-
} else {
|
|
85
|
-
var accesskey = btn.getAttribute("accesskey");
|
|
86
|
-
}
|
|
87
|
-
if (!accesskey) return;
|
|
88
|
-
keyMap[accesskey.toUpperCase()] = btn;
|
|
89
|
-
};
|
|
90
56
|
function button(texter, type) {
|
|
91
57
|
var tracker = createElement(track);
|
|
92
58
|
var _texter;
|
package/coms/zimoli/data.js
CHANGED
|
@@ -1048,7 +1048,8 @@ function getItem(instanceId, onlyFromLocalStorage = false) {
|
|
|
1048
1048
|
return data;
|
|
1049
1049
|
}
|
|
1050
1050
|
function hasItem(instanceId) {
|
|
1051
|
-
|
|
1051
|
+
const storageId = userPrefix + instanceId + pagePathName;
|
|
1052
|
+
return sessionStorage.getItem(storageId) || localStorage.getItem(storageId);
|
|
1052
1053
|
}
|
|
1053
1054
|
var instanceListenerMap = {};
|
|
1054
1055
|
var fireListener = function (instanceId, data) {
|
package/coms/zimoli/menu.js
CHANGED
|
@@ -148,20 +148,24 @@ function main(elem, mode) {
|
|
|
148
148
|
case "x":
|
|
149
149
|
case "horizonal":
|
|
150
150
|
var direction = 'x';
|
|
151
|
+
mode = "horizonal";
|
|
151
152
|
case "v":
|
|
152
153
|
case "y":
|
|
153
154
|
case "vertical":
|
|
154
|
-
var emit = function (item) {
|
|
155
|
-
active(elem, item, item.value);
|
|
155
|
+
var emit = function (item, target) {
|
|
156
|
+
active(elem, item, item.value, target);
|
|
156
157
|
};
|
|
157
158
|
if ("$src" in elem) {
|
|
158
159
|
getGenerator(elem);
|
|
159
160
|
care(elem, function (src) {
|
|
160
161
|
menuList(elem, getTreeFromData(src), emit, direction);
|
|
162
|
+
elem.registerAsRoot();
|
|
161
163
|
});
|
|
162
|
-
}
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
163
166
|
var nodes = getArrayNodes(elem);
|
|
164
|
-
elem = menuList(elem, nodes, emit);
|
|
167
|
+
elem = menuList(elem, nodes, emit, direction);
|
|
168
|
+
elem.registerAsRoot();
|
|
165
169
|
}
|
|
166
170
|
break;
|
|
167
171
|
default:
|
package/coms/zimoli/menu.less
CHANGED
|
@@ -92,12 +92,19 @@ body:active & {
|
|
|
92
92
|
display: block;
|
|
93
93
|
overflow: hidden;
|
|
94
94
|
text-overflow: hidden;
|
|
95
|
-
height: 40px;
|
|
95
|
+
line-height: 40px;
|
|
96
96
|
position: relative;
|
|
97
|
-
border: 1px solid #18333c;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
border-bottom: 1px solid #18333c;
|
|
98
|
+
padding: 0;
|
|
99
|
+
|
|
100
|
+
menu-item {
|
|
101
|
+
display: inline-block;
|
|
102
|
+
|
|
103
|
+
&.has-children:after {
|
|
104
|
+
padding-top: 3px;
|
|
105
|
+
content: "﹀";
|
|
106
|
+
}
|
|
107
|
+
}
|
|
101
108
|
|
|
102
109
|
>div {
|
|
103
110
|
vertical-align: top;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
<i ng-class="
|
|
2
|
-
<span ng-
|
|
1
|
+
<i ng-class="icon" ng-if='useIcon||hasIcon'></i>
|
|
2
|
+
<span ng-html="name"></span>
|
|
3
3
|
<s></s>
|
package/coms/zimoli/menuItem.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
function main(elem, scope, hasIcon) {
|
|
2
2
|
var item = elem || document.createElement('menu-item');
|
|
3
3
|
item.innerHTML = menuItem;
|
|
4
|
-
if (isObject(scope) && scope !==
|
|
5
|
-
render(item, { menu: scope, useIcon: hasIcon, hasIcon })
|
|
4
|
+
if (isObject(scope) && scope !== item.$scope) {
|
|
6
5
|
}
|
|
7
6
|
else {
|
|
8
|
-
|
|
7
|
+
var scope = item.$scope;
|
|
9
8
|
}
|
|
9
|
+
if (scope.menu) scope = scope.menu;
|
|
10
|
+
var name = scope.name;
|
|
11
|
+
var icon = scope.icon;
|
|
12
|
+
if (hasIcon === undefined) hasIcon = !!icon;
|
|
13
|
+
render(item.children, { useIcon: hasIcon, hasIcon, name, icon });
|
|
10
14
|
return item;
|
|
11
15
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<menu-item ng-repeat="menu in menus" ng-if="!menu.hidden" ng-click="open(
|
|
2
|
-
ng-mouseleave="
|
|
1
|
+
<menu-item ng-repeat="menu in menus" ng-if="!menu.hidden" ng-click="open.call(this)"
|
|
2
|
+
ng-mouseleave="cancel()" ng-mouseenter="popMenu.call(this)"
|
|
3
3
|
ng-class="{'has-children':menu.children&&menu.children.length,'warn':menu.type==='danger'||menu.type==='warn'||menu.type==='red'}">
|
|
4
4
|
</menu-item>
|
package/coms/zimoli/menuList.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var mounted_menus = [], releaseTimer = 0;
|
|
1
|
+
var mounted_menus = [], releaseTimer = 0, root_menu;
|
|
2
2
|
var release = function () {
|
|
3
3
|
clear();
|
|
4
4
|
releaseTimer = setTimeout(function () {
|
|
@@ -8,46 +8,231 @@ var release = function () {
|
|
|
8
8
|
var clear = function () {
|
|
9
9
|
clearTimeout(releaseTimer);
|
|
10
10
|
};
|
|
11
|
+
var unfocus = function () {
|
|
12
|
+
remove(mounted_menus);
|
|
13
|
+
this.ispop = false;
|
|
14
|
+
this.setFocus();
|
|
15
|
+
};
|
|
16
|
+
var setFocus = function (focused = this.firstMenu) {
|
|
17
|
+
var page = this;
|
|
18
|
+
if (page.ispop || page === document.activeElement) {
|
|
19
|
+
if (page.focused !== focused) {
|
|
20
|
+
if (page.focused) removeClass(page.focused, 'focus');
|
|
21
|
+
if (focused) addClass(focused, "focus");
|
|
22
|
+
page.focused = focused;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
if (page.focused) {
|
|
27
|
+
removeClass(page.focused, 'focus');
|
|
28
|
+
page.focused = null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var moveFocus = function (delta) {
|
|
33
|
+
var page = this;
|
|
34
|
+
var focused = page.focused;
|
|
35
|
+
var newIndex = 0;
|
|
36
|
+
if (!focused) {
|
|
37
|
+
if (delta > 0) newIndex = 0;
|
|
38
|
+
else newIndex = page.total - 1;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
var newIndex = focused.index + delta;
|
|
42
|
+
var total = page.total;
|
|
43
|
+
if (page !== root_menu) {
|
|
44
|
+
total++;
|
|
45
|
+
}
|
|
46
|
+
if (newIndex < 0) newIndex = total + newIndex;
|
|
47
|
+
if (newIndex > total - 1) newIndex = newIndex - total;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
var e = page.getIndexedElement(newIndex);
|
|
51
|
+
if (!e) page.setFocus(null);
|
|
52
|
+
else page.open(e);
|
|
53
|
+
};
|
|
54
|
+
var openFocus = function () {
|
|
55
|
+
var menu = mounted_menus[mounted_menus.length - 1] || root_menu;
|
|
56
|
+
if (!menu.ispop) menu.ispop = 1;
|
|
57
|
+
menu.open(menu.focused);
|
|
58
|
+
};
|
|
59
|
+
var closeFocus = function () {
|
|
60
|
+
var menu = mounted_menus[mounted_menus.length - 1];
|
|
61
|
+
remove(menu);
|
|
62
|
+
};
|
|
63
|
+
var keyAction = function (deltax, deltay) {
|
|
64
|
+
if (root_menu !== document.activeElement) return;
|
|
65
|
+
var menu = mounted_menus[mounted_menus.length - 1];
|
|
66
|
+
if (menu) var parent = mounted_menus[mounted_menus.length - 2] || root_menu;
|
|
67
|
+
else menu = root_menu;
|
|
68
|
+
|
|
69
|
+
if (menu.direction === 'y') {
|
|
70
|
+
if (deltax === 1) {
|
|
71
|
+
if (menu.focused) openFocus();
|
|
72
|
+
else if (parent && parent.direction !== 'y') {
|
|
73
|
+
parent.moveFocus(deltax);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else if (deltax === -1) {
|
|
77
|
+
if (parent) {
|
|
78
|
+
if (parent.direction === 'y') remove(mounted_menus.pop());
|
|
79
|
+
else if (!menu.focused) parent.moveFocus(deltax);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
menu.moveFocus(deltay);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
if (deltay === 1) {
|
|
88
|
+
if (menu.focused) openFocus();
|
|
89
|
+
else if (parent && parent.direction === 'y') {
|
|
90
|
+
parent.moveFocus(deltay);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else if (deltay === -1) {
|
|
94
|
+
if (parent) {
|
|
95
|
+
if (parent.direction !== 'y') remove(mounted_menus.pop());
|
|
96
|
+
else if (!menu.focused) parent.moveFocus(deltay);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
menu.moveFocus(deltax);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
function keyalt() {
|
|
105
|
+
if (root_menu === document.activeElement) root_menu.blur();
|
|
106
|
+
else {
|
|
107
|
+
root_menu.tabIndex = 0;
|
|
108
|
+
root_menu.focus();
|
|
109
|
+
}
|
|
110
|
+
root_menu.setFocus();
|
|
111
|
+
}
|
|
112
|
+
function keyesc() {
|
|
113
|
+
if (root_menu === document.activeElement && !mounted_menus.length) {
|
|
114
|
+
if (!root_menu.ispop) root_menu.blur(), root_menu.setFocus();
|
|
115
|
+
else root_menu.ispop = false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function keyup() {
|
|
119
|
+
keyAction(0, -1);
|
|
120
|
+
}
|
|
121
|
+
function keydown() {
|
|
122
|
+
keyAction(0, 1);
|
|
123
|
+
}
|
|
124
|
+
function keyleft() {
|
|
125
|
+
keyAction(-1, 0)
|
|
126
|
+
}
|
|
127
|
+
function keyright() {
|
|
128
|
+
keyAction(1, 0);
|
|
129
|
+
}
|
|
130
|
+
function keyspace() {
|
|
131
|
+
if (root_menu !== document.activeElement) return;
|
|
132
|
+
var menu = mounted_menus[mounted_menus.length - 1];
|
|
133
|
+
if (!menu || !menu.focused) menu = mounted_menus[mounted_menus.length - 2] || root_menu;
|
|
134
|
+
if (menu.focused) {
|
|
135
|
+
menu.focused.click();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function register() {
|
|
139
|
+
// on('keydown.alt')(window, e => e.preventDefault());
|
|
140
|
+
on('keydown.alt.')(window, keyalt);
|
|
141
|
+
on('keydown.esc')(window, keyesc);
|
|
142
|
+
on('keydown.left')(window, keyleft);
|
|
143
|
+
on('keydown.right')(window, keyright);
|
|
144
|
+
on('keydown.up')(window, keyup);
|
|
145
|
+
on('keydown.down')(window, keydown);
|
|
146
|
+
on('keydown.enter')(window, keyspace);
|
|
147
|
+
on('keydown.space')(window, keyspace);
|
|
148
|
+
root_menu = this;
|
|
149
|
+
}
|
|
11
150
|
function main(page, items, active, direction = 'y') {
|
|
12
151
|
if (!isNode(page)) {
|
|
13
152
|
var page = div();
|
|
14
153
|
}
|
|
15
154
|
var main = this;
|
|
16
|
-
|
|
17
|
-
|
|
155
|
+
if (direction !== 'x') page.ispop = true;
|
|
156
|
+
function popMenu(item, target) {
|
|
157
|
+
if (page.actived) {
|
|
18
158
|
clear();
|
|
19
|
-
remove(page.
|
|
159
|
+
remove(page.actived);
|
|
20
160
|
}
|
|
161
|
+
page.setFocus(target);
|
|
21
162
|
if (!item.children || !item.children.length) return;
|
|
22
163
|
var clone = template.cloneNode();
|
|
164
|
+
clone.$parentScopes = page.$parentScopes;
|
|
165
|
+
clone.$src = src;
|
|
23
166
|
clone.innerHTML = template.innerHTML;
|
|
24
167
|
var menu = main(clone, item.children, active);
|
|
25
168
|
mounted_menus.push(menu);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
popup(menu,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
169
|
+
page.actived = menu;
|
|
170
|
+
menu.root = page.root || page;
|
|
171
|
+
popup(menu, target);
|
|
172
|
+
if (page.ispop === true) {
|
|
173
|
+
var offleave0 = on("mouseleave")(target, release);
|
|
174
|
+
var offleave1 = on("mouseleave")(menu, release);
|
|
175
|
+
var offenter0 = on("mouseenter")(target, clear);
|
|
176
|
+
var offenter1 = on("mouseenter")(menu, clear);
|
|
177
|
+
} else {
|
|
178
|
+
page.ispop = 1;
|
|
179
|
+
page.tabIndex = 0;
|
|
180
|
+
page.focus();
|
|
181
|
+
}
|
|
182
|
+
on("mousedown")(menu, e => e.preventDefault());
|
|
33
183
|
once("remove")(menu, function () {
|
|
34
|
-
removeFromList(mounted_menus,
|
|
35
|
-
offleave0();
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
offenter1();
|
|
184
|
+
removeFromList(mounted_menus, this);
|
|
185
|
+
if (offleave0) offleave0();
|
|
186
|
+
if (offleave1) offleave1();
|
|
187
|
+
if (offenter0) offenter0();
|
|
188
|
+
if (offenter1) offenter1();
|
|
39
189
|
});
|
|
40
190
|
}
|
|
41
|
-
|
|
42
|
-
var template = page.tempalte ||
|
|
191
|
+
if (!page.ispop) on("blur")(page, unfocus);
|
|
192
|
+
var template = page.tempalte || document.createElement("ylist");
|
|
43
193
|
if (!page.tempalte) {
|
|
44
194
|
template.className = '';
|
|
45
195
|
template.removeAttribute('mode');
|
|
46
196
|
template.innerHTML = page.innerHTML;
|
|
47
197
|
page.tempalte = template;
|
|
48
198
|
}
|
|
199
|
+
var popTimer = 0;
|
|
200
|
+
var open = function () {
|
|
201
|
+
cancel();
|
|
202
|
+
var elem = this;
|
|
203
|
+
page.setFocus(elem);
|
|
204
|
+
if (page.ispop) popTimer = setTimeout(function () {
|
|
205
|
+
popMenu(elem.menu, elem);
|
|
206
|
+
}, 60);
|
|
207
|
+
};
|
|
208
|
+
var cancel = function () {
|
|
209
|
+
clearTimeout(popTimer);
|
|
210
|
+
}
|
|
211
|
+
var fire = function () {
|
|
212
|
+
cancel();
|
|
213
|
+
var pop = active(this.menu, this);
|
|
214
|
+
if (pop === false) return;
|
|
215
|
+
var root = page.root || page;
|
|
216
|
+
if (root.ispop === 1) root.ispop = false;
|
|
217
|
+
if (page.actived && page.actived.target === this) {
|
|
218
|
+
if (!mounted_menus.length) {
|
|
219
|
+
popMenu(this.menu, this);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
unfocus.call(page);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
while (mounted_menus.length && mounted_menus[mounted_menus.length - 1] !== page) remove(mounted_menus.pop());
|
|
227
|
+
popMenu(this.menu, this);
|
|
228
|
+
if (!page.actived) {
|
|
229
|
+
(page.root || page).blur();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
|
|
49
235
|
if (!page.children.length || page.menutype === 1) {
|
|
50
|
-
page.innerHTML = menuList;
|
|
51
236
|
page.menutype = 1;
|
|
52
237
|
var hasIcon = function () {
|
|
53
238
|
var menus = items;
|
|
@@ -58,42 +243,93 @@ function main(page, items, active, direction = 'y') {
|
|
|
58
243
|
}
|
|
59
244
|
return false;
|
|
60
245
|
};
|
|
61
|
-
|
|
62
|
-
"menu-item": function () {
|
|
63
|
-
|
|
64
|
-
menuItem
|
|
246
|
+
var $scope = {
|
|
247
|
+
"menu-item": function (e, s) {
|
|
248
|
+
var a = bindAccesskey(
|
|
249
|
+
menuItem(e, s, this.hasIcon)
|
|
65
250
|
);
|
|
251
|
+
if (!page.firstMenu) {
|
|
252
|
+
page.firstMenu = a;
|
|
253
|
+
}
|
|
254
|
+
return a;
|
|
66
255
|
},
|
|
67
256
|
menus: items,
|
|
68
257
|
hasIcon: hasIcon(),
|
|
69
|
-
open
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
258
|
+
open: fire,
|
|
259
|
+
cancel,
|
|
260
|
+
popMenu: open,
|
|
261
|
+
};
|
|
262
|
+
if (page.$src) {
|
|
263
|
+
var src = page.$src;
|
|
264
|
+
var parentScopes = page.$parentScopes;
|
|
265
|
+
var itemName = src.itemName;
|
|
266
|
+
var className = `{'has-children':${itemName}.children&&${itemName}.children.length,'warn':${itemName}.type==='danger'||${itemName}.type==='warn'||${itemName}.type==='red'}`;
|
|
267
|
+
var notHidden = `!${itemName}.hidden`;
|
|
268
|
+
|
|
269
|
+
list(page, function (index) {
|
|
270
|
+
var item = items[index];
|
|
271
|
+
if (!item) return;
|
|
272
|
+
var a = $scope["menu-item"](null, item);
|
|
273
|
+
var scope = {};
|
|
274
|
+
if (item instanceof Item) item = item.value;
|
|
275
|
+
if (src.itemName) scope[src.itemName] = item;
|
|
276
|
+
else scope.$item = item;
|
|
277
|
+
if (src.keyName) scope[src.keyName] = index;
|
|
278
|
+
else scope.$key = index;
|
|
279
|
+
if (src.indexName) scope[src.indexName] = index;
|
|
280
|
+
else scope.$index = index;
|
|
281
|
+
if (src.srcName) scope[src.srcName] = items;
|
|
282
|
+
if (src.itemName) a.setAttribute("e-if", notHidden);
|
|
283
|
+
a.menu = item;
|
|
284
|
+
on("mouseleave")(a, cancel);
|
|
285
|
+
on("mouseenter")(a, open);
|
|
286
|
+
on("click")(a, fire);
|
|
287
|
+
a.setAttribute("e-class", className);
|
|
288
|
+
render(a, scope, parentScopes);
|
|
289
|
+
return a;
|
|
290
|
+
});
|
|
291
|
+
on("append")(page, function () {
|
|
292
|
+
this.go(0);
|
|
293
|
+
})
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
page.innerHTML = menuList;
|
|
297
|
+
render(page, $scope);
|
|
298
|
+
vbox(page);
|
|
299
|
+
}
|
|
300
|
+
page.total = items.length;
|
|
81
301
|
page.renders.unshift(function () {
|
|
82
302
|
this.$scope.hasIcon = hasIcon();
|
|
83
303
|
});
|
|
84
|
-
}
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
85
306
|
var generator = getGenerator(page);
|
|
307
|
+
|
|
86
308
|
list(page, function (index) {
|
|
87
309
|
var elem = generator(index);
|
|
88
310
|
if (!elem) return;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
311
|
+
if (!page.firstMenu) {
|
|
312
|
+
page.firstMenu = elem;
|
|
313
|
+
page.total = this.src.length;
|
|
314
|
+
}
|
|
315
|
+
elem.menu = this.src[index];
|
|
316
|
+
on("mouseleave")(elem, cancel);
|
|
317
|
+
on("mouseenter")(elem, open);
|
|
318
|
+
on("click")(elem, fire);
|
|
95
319
|
return elem;
|
|
96
320
|
}, direction);
|
|
97
321
|
}
|
|
322
|
+
page.open = function (a) {
|
|
323
|
+
open.call(a);
|
|
324
|
+
};
|
|
325
|
+
page.active = function (a) {
|
|
326
|
+
fire.call(a);
|
|
327
|
+
};
|
|
328
|
+
page.registerAsRoot = register;
|
|
329
|
+
page.setFocus = setFocus;
|
|
330
|
+
page.moveFocus = moveFocus;
|
|
331
|
+
page.openFocus = openFocus;
|
|
332
|
+
page.closeFocus = closeFocus;
|
|
333
|
+
page.direction = direction;
|
|
98
334
|
return page;
|
|
99
335
|
}
|
package/coms/zimoli/on.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var is_addEventListener_enabled = "addEventListener" in window;
|
|
3
3
|
var handlersMap = {};
|
|
4
4
|
var changes_key = 'changes';
|
|
5
|
-
var eventtypereg = /(?:\.once|\.prevent|\.stop|\.capture|\.self|\.passive|\.[a-z0-9]+)
|
|
5
|
+
var eventtypereg = /(?:\.once|\.prevent|\.stop|\.capture|\.self|\.passive|\.[a-z0-9]+)+\.?$/i;
|
|
6
6
|
var keyCodeMap = {
|
|
7
7
|
backspace: 8,
|
|
8
8
|
tab: 9,
|
|
@@ -118,6 +118,9 @@ var parseEventTypes = function (eventtypes) {
|
|
|
118
118
|
case "ctrl":
|
|
119
119
|
keyneed.push(t);
|
|
120
120
|
break;
|
|
121
|
+
case "":
|
|
122
|
+
if (!types.keyCode) types.keyCode = true;
|
|
123
|
+
break;
|
|
121
124
|
default:
|
|
122
125
|
if (isFinite(t)) {
|
|
123
126
|
types.keyCode = +t;
|
|
@@ -133,12 +136,20 @@ var parseEventTypes = function (eventtypes) {
|
|
|
133
136
|
return types;
|
|
134
137
|
}
|
|
135
138
|
function checkKeyNeed(eventtypes, e) {
|
|
139
|
+
var keyneed = eventtypes.keyNeed;
|
|
136
140
|
if (eventtypes.keyNeed) {
|
|
137
|
-
for (var cx = 0, dx =
|
|
138
|
-
var key =
|
|
141
|
+
for (var cx = 0, dx = keyneed.length; cx < dx; cx++) {
|
|
142
|
+
var key = keyneed[cx];
|
|
139
143
|
if (!e[key + "Key"]) return false;
|
|
140
144
|
}
|
|
141
145
|
}
|
|
146
|
+
if (eventtypes.keyCode === true) {
|
|
147
|
+
for (var cx = 0, dx = keyneed.length; cx < dx; cx++) {
|
|
148
|
+
var key = keyneed[cx];
|
|
149
|
+
if (e.keyCode === keyCodeMap[key]) return true;
|
|
150
|
+
}
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
142
153
|
if (eventtypes.keyCode) {
|
|
143
154
|
return e.keyCode === eventtypes.keyCode;
|
|
144
155
|
}
|