efront 3.10.7 → 3.11.3

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.
@@ -118,7 +118,7 @@ var scan = function (text) {
118
118
  }
119
119
 
120
120
  if (/^\-(\s|$)/.test(row)) {
121
- if (data || span > spacesize) push();
121
+ if (data || span >= spacesize) push();
122
122
  if (!parents[spacesize]) {
123
123
  var obj = [];
124
124
  push(obj);
@@ -33,11 +33,23 @@
33
33
  };
34
34
  var parseMenuList = function (items) {
35
35
  if (items instanceof Array) {
36
- console.log(items)
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
+ }
37
48
  return items;
38
49
  }
39
50
  if (items instanceof Object) {
40
51
  var keys = Object.keys(items);
52
+
41
53
  items = keys.map(k => {
42
54
  var c = items[k];
43
55
  var item = {};
@@ -55,7 +67,8 @@
55
67
  if (/,/.test(name)) {
56
68
  var [name, ...roles] = name.split(',');
57
69
  }
58
- item.name = name;
70
+ if (/^\-+$/.test(name)) item.line = true;
71
+ else item.name = name;
59
72
  if (roles) item.roles = roles;
60
73
  if (path) item.path = path;
61
74
  if (data) item.params = parseKV(data);
@@ -69,6 +82,8 @@
69
82
  return [];
70
83
  };
71
84
  result.update = function (items) {
85
+ delete result.loading_promise;
86
+ delete result.then;
72
87
  items = parseMenuList(items);
73
88
  items.map(getChildren);
74
89
  var opened = data.getInstance("menu-opened");
@@ -175,10 +190,19 @@
175
190
  result.load(result.active);
176
191
  return result;
177
192
  };
178
- result.fetch = function (url) {
179
- 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;
180
196
  return result;
181
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
+ };
182
206
  result.update(items);
183
207
  return result;
184
208
  });
@@ -19,6 +19,7 @@ function Item(value) {
19
19
  this.icon = value.icon;
20
20
  this.color = value.color;
21
21
  this.test = value.test;
22
+ this.line = value.line;
22
23
  }
23
24
  this.count = 0;//子项中的叶子节点数
24
25
  this.total = 0;//子项中的节点数
@@ -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
+ }
@@ -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;
@@ -18,7 +18,8 @@
18
18
  outline: none;
19
19
  user-select: none;
20
20
  }
21
- >.label{
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 #6fc3;
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 empty = function (index, item) {
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 || empty;
10
- var template = document.createElement("div");
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.concat(container.$scope);
29
- return container.$generator = function (index, com) {
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
- var template1 = template.cloneNode(true);
36
- if (!template1.childNodes.length) return template1;
37
- var item = template1.childNodes[0];
38
- item.with = [].concat.apply([], template1.childNodes).slice(1);
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(item, newScope, scopes);
48
- if (item.with.length) newItem.with = render(item.with, newScope, scopes);
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(item, newScope, scopes);
69
- newItem.with = render(newItem.with = item.with, newScope, scopes);
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
  };
@@ -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;
@@ -148,20 +149,24 @@ function main(elem, mode) {
148
149
  case "x":
149
150
  case "horizonal":
150
151
  var direction = 'x';
152
+ mode = "horizonal";
151
153
  case "v":
152
154
  case "y":
153
155
  case "vertical":
154
- var emit = function (item) {
155
- active(elem, item, item.value);
156
+ var emit = function (item, target) {
157
+ active(elem, item, item.value, target);
156
158
  };
157
159
  if ("$src" in elem) {
158
- getGenerator(elem);
160
+ getGenerator(elem, 'menu-item');
159
161
  care(elem, function (src) {
160
162
  menuList(elem, getTreeFromData(src), emit, direction);
163
+ elem.registerAsRoot();
161
164
  });
162
- } else {
165
+ }
166
+ else {
163
167
  var nodes = getArrayNodes(elem);
164
- elem = menuList(elem, nodes, emit);
168
+ elem = menuList(elem, nodes, emit, direction);
169
+ elem.registerAsRoot();
165
170
  }
166
171
  break;
167
172
  default:
@@ -92,22 +92,30 @@ body:active & {
92
92
  display: block;
93
93
  overflow: hidden;
94
94
  text-overflow: hidden;
95
- height: 40px;
96
95
  position: relative;
97
- border: 1px solid #18333c;
98
- background-color: #18333c;
99
- box-shadow: inset 0 0 12px #51ddf6, inset 0px -120px 120px -120px #51ddf6;
96
+ border-bottom: 1px solid #18333c;
97
+ border-top: none;
98
+ border-left: none;
100
99
  border-right: none;
100
+ padding: 0;
101
+
102
+ menu-item {
103
+ line-height: 24px;
104
+ display: inline-block;
105
+
106
+ &.has-children:after {
107
+ padding-top: 3px;
108
+ content: "﹀";
109
+ }
110
+ }
101
111
 
102
112
  >div {
103
113
  vertical-align: top;
104
114
  }
105
115
 
106
- .button {
107
- line-height: 40px;
108
- }
109
116
  }
110
117
 
118
+ &[mode=tree],
111
119
  &[mode=tree],
112
120
  &[type=tree],
113
121
  &[mode=inline],
@@ -115,46 +123,46 @@ body:active & {
115
123
  height: auto;
116
124
  box-shadow: none;
117
125
  padding: 0;
118
- margin: 0;
119
-
120
- // &[browser=samsung] {
121
- // .tab1 {
122
- // &.open s {
123
- // overflow : visible;
124
- // text-indent: -6.6pt;
125
- // }
126
- // &.closed s{
127
- // overflow : visible;
128
- // text-indent: 3.1pt;
129
- // }
130
- // }
131
- // }
132
-
133
- // &[browser=firefox] {
134
- // .tab1 {
135
- // &.open s {
136
- // text-indent: -8.6px;
137
- // }
138
-
139
- // &.closed s {
140
- // text-indent: -4.1px;
141
- // }
142
- // }
143
- // }
144
-
145
- // &[browser=safari] {
146
- // .tab1 {
147
- // &.open s {
148
- // text-indent: -5.6px;
149
- // }
150
-
151
- // &.closed s {
152
- // text-indent: -1.1px;
153
- // }
154
- // }
155
- // }
156
-
157
- .tab1 {
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
+
158
166
  &.open {
159
167
  color: #fff;
160
168
  background: #1e282c;
@@ -211,45 +219,13 @@ body:active & {
211
219
 
212
220
  border-left: 3px solid transparent;
213
221
  display : block;
214
- height : 44px;
215
- line-height: 44px;
216
222
  font-size : 14px;
217
223
  color : #b8c7ce;
218
224
  }
219
225
 
220
- >.button {
221
- box-shadow: none;
222
-
223
-
224
- >b {
225
- font-weight: normal;
226
- }
227
-
228
- &:not(.tab1) {
229
- display: block;
230
- height: 36px;
231
- line-height: 36px;
232
- font-size: 14px;
233
- background: #2c3b41;
234
- color: #8aa4af;
235
-
236
- &.checked,
237
- &.actived,
238
- &.selected {
239
- color: #fff;
240
- }
241
- }
242
-
243
- i {
244
- margin-right: 10px;
245
- }
246
-
247
-
248
- &.hover {
249
- text-shadow: none;
250
- color: #fff;
251
- }
252
-
226
+ >[line],
227
+ >.line {
228
+ line-height: 0;
229
+ font-size: 0;
253
230
  }
254
-
255
231
  }
@@ -1,3 +1,3 @@
1
- <i ng-class="menu.icon" ng-if='useIcon||hasIcon||menu.icon'></i>
2
- <span ng-model="menu.name"></span>
1
+ <i ng-class="icon" ng-if='useIcon||hasIcon'></i>
2
+ <span ng-html="name"></span>
3
3
  <s></s>
@@ -1,11 +1,17 @@
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;
4
- if (isObject(scope) && scope !== elem.$scope) {
5
- render(item, { menu: scope, useIcon: hasIcon, hasIcon })
5
+ if (isObject(scope) && scope !== item.$scope) {
6
6
  }
7
7
  else {
8
- extendIfNeeded(elem.$scope, { useIcon: false, hasIcon: false })
8
+ var scope = item.$scope;
9
9
  }
10
+ if (scope.menu) scope = scope.menu;
11
+ var name = scope.name;
12
+ var icon = scope.icon;
13
+ if (hasIcon === undefined) hasIcon = !!icon;
14
+ render(item.children, { useIcon: hasIcon, hasIcon, name, icon });
15
+ if (scope.line) item.setAttribute("line", ''), on("click")(item, preventDefault);
10
16
  return item;
11
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
  }
@@ -1,4 +1,4 @@
1
- <menu-item ng-repeat="menu in menus" ng-if="!menu.hidden" ng-click="open(menu,event)"
2
- ng-mouseleave="clearTimeout(popTimer)" ng-mouseenter="popTimer=popMenu(menu,event)"
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>