efront 3.15.7 → 3.16.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.
@@ -1,3 +1,4 @@
1
+ cross.addDirect(/^https?\:\/\/([[a-z\.\d\:\/%]+\]|[\d\.]+)(\:\d+)?\//);
1
2
  var fields = refilm`
2
3
  地址/ip
3
4
  地理位置/ip ${function (e) {
@@ -20,9 +21,37 @@ var fields = refilm`
20
21
  启动时间/time ${function (e) {
21
22
  e.innerHTML = filterTime(e.data[e.field.key]);
22
23
  }}
23
- 端口/port input
24
- 版本/version
25
- 进程/pid
24
+ 端口/port ${async function (e) {
25
+ var { data, field } = e;
26
+ var ports = data[field.key].split(/,/);
27
+ var loaded = [];
28
+ for (var p of ports) {
29
+ var p0 = p;
30
+ var protocol = /^https/.test(p) ? "https://" : "http://";
31
+ p = p.replace(/[^\d]+/g, '');
32
+ if (p) p = ":" + p;
33
+ try {
34
+ var ip = data.ip;
35
+ if (/^::ffff:\d+\.\d+\.\d+\.\d+$/i.test(ip)) {
36
+ ip = ip.slice(7);
37
+ }
38
+ else {
39
+ ip = `[${ip}]`;
40
+ }
41
+ var xhr = await cross("options", `${protocol}${ip}${p}/:version`);
42
+ if (xhr.responseText === 'efront ' + data.version) {
43
+ loaded.push(`<span style="color:green">${p0}</span>`);
44
+ } else {
45
+ loaded.push(`<span style="color:red">${p0}</span>`);
46
+ }
47
+ } catch (e) {
48
+ loaded.push(`<span style="color:gray">${p0}</span>`);
49
+ }
50
+ e.innerHTML = loaded.join('');
51
+ }
52
+ }}
53
+ 版本 / version text
54
+ 进程 / pid
26
55
  `;
27
56
  function main() {
28
57
  var page = div();
@@ -1,3 +1,4 @@
1
+ var isEmpty = require("./isEmpty");
1
2
  var convertReg = /^(?:object|function)$/;
2
3
  var check = function (o) {
3
4
  return o === null || typeof o === 'bigint' || o instanceof BigInt || typeof o === 'number' || typeof o === "boolean";
@@ -24,16 +25,23 @@ var join = function (o) {
24
25
  if (o instanceof RegExp) return regexp(o);
25
26
  var arr = o[""];
26
27
  delete o[""];
28
+ var typeid = o._;
29
+ delete o._;
27
30
  var pairs = [].concat(arr);
28
31
  for (var k in o) {
29
32
  pairs.push(k + ':' + o[k]);
30
33
  }
34
+ var s;
31
35
  if (o instanceof Array) {
32
- return `[${pairs.join(',')}]`;
36
+ s = `[${pairs.join(',')}]`;
33
37
  }
34
- return `{${pairs.join(',')}}`;
35
- }
36
- function stringify(memery) {
38
+ else {
39
+ s = `{${pairs.join(',')}}`;
40
+ }
41
+ if (typeid > 0) s = typeid + s;
42
+ return s;
43
+ };
44
+ function stringify(memery, preload) {
37
45
  if (memery === undefined) return '';
38
46
  if (check(memery)) return String(memery);
39
47
  if (typeof memery === 'symbol') return symbol(memery);
@@ -48,15 +56,18 @@ function stringify(memery) {
48
56
  var rest = [memery];
49
57
  var trimed = [memery instanceof Array ? [] : {}];
50
58
  var objects = [trimed[0]];
59
+ if (!isEmpty(preload)) dist = dist.concat(preload);
51
60
  while (rest.length) {
52
61
  var memery = rest.shift();
53
62
  var o = objects.shift();
54
63
  var inc = 0, arr = [];
55
64
  o[""] = arr;
65
+ o._ = dist.indexOf(memery.constructor);
56
66
  for (var k in memery) {
57
67
  var m = memery[k];
58
68
  f: if (typeof m === 'function') {
59
69
  for (var k in m) break f;
70
+ if (dist.indexOf(m) >= 0) break f;
60
71
  continue;
61
72
  }
62
73
  if (inc === +k && k !== '') {
@@ -101,7 +112,9 @@ function stringify(memery) {
101
112
  }
102
113
  }
103
114
  }
104
- return trimed.map(join).join(',');
115
+ var result = trimed.map(join).join(',');
116
+ if (trimed.length === 1) result += ',';
117
+ return result;
105
118
  }
106
119
  var create = function (a, dst) {
107
120
  if (!a) return;
@@ -117,9 +130,10 @@ var create = function (a, dst) {
117
130
  }
118
131
  dst[""] = rest;
119
132
  };
120
- function parse(string) {
133
+ function parse(string, preload) {
121
134
  string = String(string);
122
135
  var trimed = [];
136
+ var reg0 = /\d+/g;
123
137
  var reg1 = /\}/g;
124
138
  var reg2 = /\]/g;
125
139
  var reg3 = /\\[\s\S]|"/g;
@@ -130,6 +144,18 @@ function parse(string) {
130
144
  for (var cx = 0, dx = string.length; cx < dx; cx++) {
131
145
  var s = string.charAt(cx);
132
146
  var reg = null, o = null;
147
+ reg0.lastIndex = 0;
148
+ var typeid = 0;
149
+ var m = reg0.test(string.charAt(cx));
150
+ if (m) {
151
+ reg0.lastIndex = cx;
152
+ var m = reg0.exec(string);
153
+ if (/^[\[\{]$/.test(string.charAt(reg0.lastIndex))) {
154
+ typeid = +m[0];
155
+ cx = reg0.lastIndex;
156
+ s = string.charAt(reg0.lastIndex);
157
+ }
158
+ }
133
159
  switch (s) {
134
160
  case ",":
135
161
  trimed.push(undefined);
@@ -148,6 +174,15 @@ function parse(string) {
148
174
  marked.push(trimed.length);
149
175
  trimed.push(o);
150
176
  cx = reg.lastIndex;
177
+ if (typeid) {
178
+ o._ = typeid;
179
+ }
180
+ if (/\d/.test(string.charAt(cx))) {
181
+ reg4.lastIndex = cx;
182
+ var m = reg4.exec(string);
183
+ o._ = typeid || string.slice(cx, m.index);
184
+ cx = reg4.lastIndex;
185
+ }
151
186
  break;
152
187
  case "/":
153
188
  reg = reg5;
@@ -176,8 +211,6 @@ function parse(string) {
176
211
  }
177
212
  trimed.push(s);
178
213
  break;
179
- case "/":
180
- break;
181
214
  default:
182
215
  reg4.lastIndex = cx + 1;
183
216
  var match = reg4.exec(string);
@@ -213,15 +246,21 @@ function parse(string) {
213
246
  trimed.push(s);
214
247
  }
215
248
  }
216
- var dist = trimed.slice(0, trimed.length);
249
+ var dist = [trimed[0]];
250
+ if (!isEmpty(preload)) dist = dist.concat(preload);
251
+ var preloads_length = dist.length - 1;
252
+ dist = dist.concat(trimed.slice(1, trimed.length));
217
253
  for (var cx = 0, dx = marked.length; cx < dx; cx++) {
218
254
  var index = marked[cx];
219
255
  var o = trimed[index];
220
- dist[index] = o instanceof Array ? [] : {};
256
+ if (index > 0) index += preloads_length;
257
+ if (o._ > 0) dist[index] = Object.create(dist[o._].prototype);
258
+ else dist[index] = o instanceof Array ? [] : {};
221
259
  }
222
260
  for (var cx = 0, dx = marked.length; cx < dx; cx++) {
223
261
  var index = marked[cx];
224
262
  var o = trimed[index];
263
+ if (index > 0) index += preloads_length;
225
264
  var t = dist[index];
226
265
  var arr = o[""];
227
266
  delete o[""];
@@ -237,10 +276,10 @@ function parse(string) {
237
276
  }
238
277
  module.exports = {
239
278
  stringify,
240
- parse(data) {
241
- if (!/^\s*([\[\{]|\[\s*\]|\{\s*\})/.test(data)) return parse(data);
242
- if (/^\s*\{[\d\,\:\s]*\}\s*,/.test(data)) return parse(data);
243
- if (/^\s*\[[\d\,\:\s]*\]\s*,/.test(data)) return parse(data);
244
- return JSON.parse(data);
279
+ parse(data, preload) {
280
+ if (!/^\s*([\[\{]|\[\s*\]|\{\s*\})/.test(data)) return parse(data, preload);
281
+ if (/^\s*\{[\d\,\:\s]*\}\s*,/.test(data)) return parse(data, preload);
282
+ if (/^\s*\[[\d\,\:\s]*\]\s*,/.test(data)) return parse(data, preload);
283
+ return JSON.parse(data, preload);
245
284
  }
246
285
  };
@@ -114,7 +114,7 @@ function cross_(jsonp, digest = noop, method, url, headers) {
114
114
  else {
115
115
  var nocross = notCross(url);
116
116
  var callback = function () {
117
- var exposeHeaders = xhr.getResponseHeader("access-control-expose-headers");
117
+ var exposeHeaders = !nocross && xhr.getResponseHeader("access-control-expose-headers");
118
118
  var exposeMap = {};
119
119
  if (exposeHeaders) exposeHeaders.split(",").forEach(h => exposeMap[h.toLowerCase()] = true);
120
120
  if (xhr.getResponseHeader) {
@@ -230,7 +230,7 @@ var killCircle = function () {
230
230
  var hasOwnProperty = {}.hasOwnProperty;
231
231
  var loadModule = function (name, then, prebuilds = {}) {
232
232
  if (/^(?:module|exports|define|require|window|global|undefined|__dirname|__filename)$/.test(name)) return then();
233
- if ((name in prebuilds) || hasOwnProperty.call(modules, name) || (window[name] !== null && window[name] !== void 0 && !hasOwnProperty.call(forceRequest, name))
233
+ if ((name in prebuilds) || hasOwnProperty.call(modules, name) || (!/^on/.test(name) && window[name] !== null && window[name] !== void 0 && !hasOwnProperty.call(forceRequest, name))
234
234
  ) return then();
235
235
  preLoad(name);
236
236
  var key = keyprefix + name;
@@ -545,7 +545,7 @@ var init = function (name, then, prebuilds) {
545
545
  if (then) then(modules[name]);
546
546
  return modules[name];
547
547
  }
548
- if (window[name] !== null && window[name] !== void 0 && !hasOwnProperty.call(forceRequest, name)) {
548
+ if (!/^on/.test(name) && window[name] !== null && window[name] !== void 0 && !hasOwnProperty.call(forceRequest, name)) {
549
549
  modules[name] = window[name]
550
550
  if (then) then(modules[name]);
551
551
  return modules[name];
@@ -119,7 +119,7 @@ var scan = function (text) {
119
119
  }
120
120
 
121
121
  if (/^\-(\s|$)/.test(row)) {
122
- if (data || span >= spacesize) push();
122
+ if (data || span && span >= spacesize) push();
123
123
  if (!parents[spacesize]) {
124
124
  var obj = [];
125
125
  push(obj);
@@ -11,8 +11,8 @@ function createSeek(express) {
11
11
  return dist;
12
12
  }
13
13
  function main(express) {
14
- if (!/\?\s*\.(?=[^\d])/.test(express)) return express;
15
- var reg = /\\[\s\S]|\?\s*(\.(?!\d))|[\:\,\+\=\-\!%\^\|\/\&\*\!\;\?\>\<~\{\}\[\]\(\)'"`\s]/g;
14
+ if (!/\?\s*\.(?=[^\d])|\?$/.test(express)) return express;
15
+ var reg = /\\[\s\S]|\?\s*(\.(?!\d)|\s*$)|[\:\,\+\=\-\!%\^\|\/\&\*\!\;\?\>\<~\{\}\[\]\(\)'"`\s]/g;
16
16
  var cache = [], queue = [];
17
17
  var exp = [];
18
18
  var instr = false;
@@ -81,7 +81,7 @@ function main(express) {
81
81
  add_exp(str);
82
82
  }
83
83
  lastIndex = match.index + m.length;
84
- if (match[1]) {
84
+ if (match[1] !== undefined) {
85
85
  exp.push(match[1]);
86
86
  }
87
87
  else if (/[\[\{\(]/.test(m)) {
@@ -3,6 +3,50 @@
3
3
  var menuid = 0;
4
4
  var savedChildren = Object.create(null);
5
5
  var savedMenus = Object.create(null);
6
+ var keymap = {};
7
+ var parseName = function (k) {
8
+ var icon, name, hotkey;
9
+ if (/(^|\s+)\./.test(k)) {
10
+ k = k.replace(/(?:^|\s+)\.([^\s,"'`]+)/, (_, m) => {
11
+ icon = m;
12
+ return '';
13
+ });
14
+ }
15
+ if (/(^|\s+)[\/\\]/.test(k)) {
16
+ k = k.replace(/(?:^|\s+)[\/\\]([\s\S]+)$/, (_, m) => {
17
+ hotkey = m;
18
+ return '';
19
+ });
20
+ }
21
+ if (/^(["'`])[\s\S]*\1/.test(k)) {
22
+ k = k.replace(/(['"`])[\s\S]\1/, (m) => {
23
+ name = strings.decode(m);
24
+ return '';
25
+ });
26
+ }
27
+ if (/,/.test(k)) {
28
+ var [k, ...roles] = k.split(',');
29
+ }
30
+ if (!icon && /\s+|\./.test(k)) {
31
+ [icon] = k.split(/\s+/);
32
+ k = k.slice(icon.length).trim();
33
+ }
34
+ if (!name) name = k;
35
+ var item = {};
36
+ if (icon) item.icon = icon.replace(/\./g, ' ');
37
+ if (name) item.name = name;
38
+ if (hotkey) {
39
+ hotkey = hotkey.split(',');
40
+ for (var k of hotkey) {
41
+ k = k.trim().toLowerCase().replace(/[\+\_\s]+/g, '.');
42
+ if (keymap[k]) console.warn("检查到两个项菜单使用了相同的快捷键", item, keymap[k]);
43
+ keymap[k] = item;
44
+ }
45
+ item.hotkey = hotkey;
46
+ }
47
+ if (roles) item.roles = roles;
48
+ return item;
49
+ }
6
50
  var getChildren = function (menu) {
7
51
  if (!menu.id) {
8
52
  menu.id = ++menuid;
@@ -52,29 +96,17 @@
52
96
 
53
97
  items = keys.map(k => {
54
98
  var c = items[k];
55
- var item = {};
99
+ var item = parseName(k);
56
100
  if (c instanceof Object) {
57
101
  item.children = parseMenuList(c);
58
102
  }
59
103
  else if (typeof c === 'string') {
60
104
  var [path, data] = c.split(/\?/);
105
+ if (data) data = data.trim();
61
106
  }
62
- var [icon] = k.split(/\s+/);
63
- if (icon.length < k.length) {
64
- item.icon = icon;
65
- var name = k.slice(icon.length).trim();
66
- } else name = k;
67
- if (/,/.test(name)) {
68
- var [name, ...roles] = name.split(',');
69
- }
70
- if (/^\-+$/.test(name)) item.line = true;
71
- else item.name = name;
72
- if (roles) item.roles = roles;
107
+ if (/^\-+$/.test(item.name)) item.line = true;
73
108
  if (path) item.path = path;
74
109
  if (data) item.params = parseKV(data);
75
- if (/,/.test(name)) {
76
-
77
- }
78
110
  item.closed = true;
79
111
  return item;
80
112
  });
@@ -85,7 +117,7 @@
85
117
  result.update = function (items) {
86
118
  delete result.loading_promise;
87
119
  delete result.then;
88
- items = parseMenuList(items);
120
+ items = result.parse(items);
89
121
  items.map(getChildren);
90
122
  var opened = data.getInstance("menu-opened");
91
123
  var historys = zimoli.getCurrentHistory();
@@ -198,7 +230,12 @@
198
230
  result.then = then;
199
231
  return result;
200
232
  };
201
- result.parse = parseMenuList;
233
+ result.parse = function (items) {
234
+ keymap = {};
235
+ items = parseMenuList(items);
236
+ items.keymap = keymap;
237
+ return items;
238
+ };
202
239
  var then = function (ok, oh) {
203
240
  if (this.loading_promise) {
204
241
  return this.loading_promise.then(ok, oh);
@@ -571,10 +571,8 @@ var privates = {
571
571
  headers = seekFromSource(headers, api.base);
572
572
  }
573
573
  cross(realmethod, uri, headers).send(params).done(e => {
574
- updateLoadingCount();
575
574
  ok(e.response || e.responseText);
576
575
  }).error(xhr => {
577
- updateLoadingCount();
578
576
  try {
579
577
  var e = getErrorMessage(parseData(xhr.response || xhr.responseText || xhr.statusText || xhr.status));
580
578
  oh({ status: xhr.status, api, params: params1, error: e, toString: getErrorMessage })
@@ -582,7 +580,6 @@ var privates = {
582
580
  oh(error);
583
581
  }
584
582
  });
585
- updateLoadingCount();
586
583
  });
587
584
  promise.search = search;
588
585
  promise.params = temp;
@@ -652,6 +649,7 @@ var getData = function () { return this.data };
652
649
  var updateLoadingCount = function () {
653
650
  data.loading_count = cross.requests.length;
654
651
  };
652
+ on('render')(window, updateLoadingCount, true);
655
653
  var data = {
656
654
  decodeStructure,
657
655
  encodeStructure,
@@ -883,12 +881,10 @@ var data = {
883
881
  headers = seekFromSource(headers, api.base);
884
882
  }
885
883
  instance.loading = cross(method, uri, headers).send(params).done(xhr => {
886
- updateLoadingCount();
887
884
  if (instance.loading !== xhr) return oh(aborted);
888
885
  instance.loading = null;
889
886
  ok(xhr.responseText || xhr.response);
890
887
  }).error(xhr => {
891
- updateLoadingCount();
892
888
  if (instance.loading !== xhr) return oh(aborted);
893
889
  instance.loading = null;
894
890
  try {
@@ -898,7 +894,6 @@ var data = {
898
894
  oh(error);
899
895
  }
900
896
  });
901
- updateLoadingCount();
902
897
  }).then(function (response) {
903
898
  return transpile(seekResponse(parseData(response), selector), api.transpile, api.root);
904
899
  });
@@ -8,6 +8,18 @@ var dispatch = "dispatchEvent" in document ? function dispatchEvent(target, even
8
8
  return target[fire] && target[fire](event);
9
9
  }
10
10
  };
11
+ /**
12
+ * @param {Event} e
13
+ */
14
+ function dispatch2(t, e) {
15
+ var on = 'on' + e.type;
16
+ var f = t[on];
17
+ var res = dispatch(t, e);
18
+ if (f && (t.nodeType !== 1 || t.constructor === window.HTMLUnknownElement)) {
19
+ return f.call(t, e) !== false;
20
+ }
21
+ return res;
22
+ }
11
23
  function main() {
12
24
  var target, event, value;
13
25
  for (var cx = 0, dx = arguments.length; cx < dx; cx++) {
@@ -27,7 +39,7 @@ function main() {
27
39
  event.value = arg;
28
40
  }
29
41
  }
30
- if (dispatch(target || window, event)) {
42
+ if (dispatch2(target || window, event)) {
31
43
  return event;
32
44
  };
33
45
  return false;
@@ -1,6 +1,6 @@
1
1
  var hasOwnProperty = {}.hasOwnProperty;
2
2
  function getValue(o = this) {
3
- if (!o) return o;
3
+ if (!isObject(o) && !isFunction(o)) return o;
4
4
  if (isFunction(o.getValue)) return o.getValue();
5
5
  if (hasOwnProperty.call(o, 'valueOf')) return o.valueOf();
6
6
  if ("key" in o) return o.key;
@@ -91,6 +91,28 @@ var getTreeNodes = function (elem) {
91
91
  return nodes;
92
92
  };
93
93
 
94
+ function bindGlobalkey(elem, keymap, emit) {
95
+ if (elem.keymap) {
96
+ for (var off of elem.keyoff) {
97
+ off();
98
+ }
99
+ }
100
+ if (!keymap) return;
101
+ var keyoff = [];
102
+ var emitEvent = function (item, event) {
103
+ event.preventDefault(true);
104
+ var $scope = {};
105
+ var { itemName } = this.$src;
106
+ if (itemName) $scope[itemName] = item;
107
+ else $scope.menu = item, $scope.$item = item;
108
+ emit(item, { $scope });
109
+ }
110
+ for (let k in keymap) {
111
+ keyoff.push(bind("keydown." + k)(elem, emitEvent.bind(elem, keymap[k])));
112
+ }
113
+ elem.keyoff = keyoff;
114
+ }
115
+
94
116
  function main(elem, mode) {
95
117
  if (isElement(elem)) {
96
118
  // var os = /Samsung|Firefox|Chrome|MSIE|Safari/i.exec(navigator.userAgent);
@@ -184,6 +206,7 @@ function main(elem, mode) {
184
206
  var src0 = [];
185
207
  menuList(elem, src0, emit, direction);
186
208
  care(elem, function (src) {
209
+ bindGlobalkey(elem, src.keymap, emit);
187
210
  src0.splice(0, src0.length);
188
211
  var s = getTreeFromData(src);
189
212
  var i = 0;
@@ -208,6 +231,7 @@ function main(elem, mode) {
208
231
  }
209
232
  if (!elem.hasAttribute('mode')) elem.setAttribute('mode', mode);
210
233
  if (!elem.hasAttribute(mode)) elem.setAttribute(mode, '');
234
+
211
235
  return elem;
212
236
 
213
237
  }
@@ -1,3 +1,6 @@
1
1
  <i ng-class="icon" ng-if='useIcon||hasIcon'></i>
2
- <span ng-html="name"></span>
2
+ <span ng-html="name?"></span>
3
+ <template -if="hotkey?">
4
+ &nbsp;&nbsp; <span ng-repeat="k of hotkey" class="hotkey" ng-html="k"></span>
5
+ </template>
3
6
  <s></s>
@@ -11,7 +11,14 @@ function main(elem, scope, hasIcon) {
11
11
  var name = scope.name;
12
12
  var icon = scope.icon;
13
13
  if (hasIcon === undefined) hasIcon = !!icon;
14
+ if (scope.disabled || scope.enabled === false) {
15
+ item.setAttribute('disabled', '');
16
+ }
17
+ else {
18
+ item.removeAttribute("disabled");
19
+ }
14
20
  render(item.children, scope, hasIcon instanceof Array ? hasIcon : [{ useIcon: hasIcon, hasIcon, name, icon }]);
15
21
  if (scope.line) item.setAttribute("line", ''), on("click")(item, preventDefault);
22
+ if (scope.hotkey) bindAccesskey(item, scope.hotkey);
16
23
  return item;
17
24
  }
@@ -1,15 +1,36 @@
1
- i{
1
+ i {
2
2
  display: inline-block;
3
3
  width: 1em;
4
4
  }
5
+
6
+ .hotkey {
7
+ margin-left: 12px;
8
+ font-size: 12px;
9
+ float: right;
10
+ }
11
+
12
+ &[disabled] {
13
+ background: #0000;
14
+
15
+ &>.track {
16
+ opacity: 0;
17
+ }
18
+
19
+ border-radius: 0;
20
+ color: #999;
21
+ }
22
+
5
23
  &.line,
6
24
  &[line] {
7
25
  box-shadow: none;
8
- >.track{
26
+
27
+ >.track {
9
28
  display: none;
10
29
  }
30
+
11
31
  line-height: 0;
12
32
  font-size: 0;
33
+
13
34
  &:after {
14
35
  content: "";
15
36
  display: block;
@@ -14,6 +14,7 @@ var unfocus = function () {
14
14
  this.setFocus(null);
15
15
  };
16
16
  var setFocus = function (focused) {
17
+ if (focused && focused.hasAttribute("disabled")) return;
17
18
  var page = this;
18
19
  if (focused) {
19
20
  if (page.focused !== focused) {
@@ -40,16 +41,17 @@ var moveFocus = function (delta) {
40
41
  else {
41
42
  var newIndex = focused.index + delta;
42
43
  var total = page.total;
43
- if (page !== root_menu) {
44
- total++;
45
- }
46
44
  if (newIndex < 0) newIndex = total + newIndex;
47
45
  if (newIndex > total - 1) newIndex = newIndex - total;
48
46
  }
49
-
50
- var e = page.getIndexedElement(newIndex);
47
+ do {
48
+ var e = page.getIndexedElement(newIndex);
49
+ if (newIndex < 0) newIndex = total + newIndex;
50
+ newIndex += delta;
51
+ } while (e && (e.hasAttribute("disabled") || e.hasAttribute("line")));
51
52
  if (!e) page.setFocus(null);
52
- else page.open(e);
53
+ else if (page.ispop !== true) page.setFocus(e), page.open(e);
54
+ else page.setFocus(e);
53
55
  };
54
56
  var openFocus = function () {
55
57
  var menu = mounted_menus[mounted_menus.length - 1] || root_menu;
@@ -68,15 +70,20 @@ var keyAction = function (deltax, deltay) {
68
70
 
69
71
  if (menu.direction === 'y') {
70
72
  if (deltax === 1) {
71
- if (menu.focused) openFocus();
73
+ // right
74
+ if (menu.focused) var fmenu = menu.focused.menu;
75
+ if (fmenu && fmenu.children && fmenu.children.length) {
76
+ openFocus();
77
+ }
72
78
  else if (parent && parent.direction !== 'y') {
73
79
  parent.moveFocus(deltax);
74
80
  }
75
81
  }
76
82
  else if (deltax === -1) {
83
+ // left
77
84
  if (parent) {
78
85
  if (parent.direction === 'y') remove(mounted_menus.pop());
79
- else if (!menu.focused) parent.moveFocus(deltax);
86
+ else parent.moveFocus(deltax);
80
87
  }
81
88
  }
82
89
  else {
@@ -85,15 +92,18 @@ var keyAction = function (deltax, deltay) {
85
92
  }
86
93
  else {
87
94
  if (deltay === 1) {
88
- if (menu.focused) openFocus();
95
+ // down
96
+ if (menu.focused) var fmenu = menu.focused.menu;
97
+ if (fmenu && fmenu.children && fmenu.children.length) openFocus();
89
98
  else if (parent && parent.direction === 'y') {
90
99
  parent.moveFocus(deltay);
91
100
  }
92
101
  }
93
102
  else if (deltay === -1) {
103
+ // up
94
104
  if (parent) {
95
105
  if (parent.direction !== 'y') remove(mounted_menus.pop());
96
- else if (!menu.focused) parent.moveFocus(deltay);
106
+ else parent.moveFocus(deltay);
97
107
  }
98
108
  }
99
109
  else {
@@ -178,11 +188,8 @@ function main(page, items, active, direction = 'y') {
178
188
  page.actived = menu;
179
189
  menu.root = page.root || page;
180
190
  popup(menu, target);
191
+ menu.setFocus(menu.firstMenu);
181
192
  if (page.ispop === true) {
182
- var offleave0 = on("mouseleave")(target, release);
183
- var offleave1 = on("mouseleave")(menu, release);
184
- var offenter0 = on("mouseenter")(target, clear);
185
- var offenter1 = on("mouseenter")(menu, clear);
186
193
  } else {
187
194
  page.ispop = 1;
188
195
  page.tabIndex = 0;
@@ -191,10 +198,6 @@ function main(page, items, active, direction = 'y') {
191
198
  on("mousedown")(menu, e => e.preventDefault());
192
199
  once("remove")(menu, function () {
193
200
  removeFromList(mounted_menus, this);
194
- if (offleave0) offleave0();
195
- if (offleave1) offleave1();
196
- if (offenter0) offenter0();
197
- if (offenter1) offenter1();
198
201
  });
199
202
  }
200
203
  on("blur")(page, unfocus);
@@ -220,12 +223,14 @@ function main(page, items, active, direction = 'y') {
220
223
  }, time || 60);
221
224
  };
222
225
  var cancel = function () {
226
+ clear();
223
227
  clearTimeout(popTimer);
224
228
  }
225
229
  var fire = function () {
226
230
  cancel();
227
231
  if (this.menu.line) return;
228
232
  if (byMousedown) return;
233
+ if (this.hasAttribute("disabled") || this.hasAttribute('line')) return;
229
234
  var pop = active(this.menu, this);
230
235
  if (pop === false) return;
231
236
  var root = page.root || page;
@@ -285,6 +290,7 @@ function main(page, items, active, direction = 'y') {
285
290
  );
286
291
  if (!page.firstMenu) {
287
292
  page.firstMenu = a;
293
+ page.total = items.length;
288
294
  }
289
295
  a.menu = s.menu;
290
296
  return a;