efront 3.18.0 → 3.18.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.
@@ -1,33 +1,42 @@
1
1
  function maps_test() {
2
- var map = new maps({
2
+ var config = {
3
3
  center: [/*兰考*/114.834364, 34.82138],
4
- center: [/*蒙古*/104.751074, 44.163022],
5
- center: [/*西亚*/48.068813, 29.321316],
6
- zoom: 12
7
- });
8
- onclick(map, function (event) {
9
- var map = this.map;
10
- var layerx = event.offsetX || event.layerX || 0;
11
- var layery = event.offsetY || event.layerY || 0;
12
- var [lng, lat] = map.location(layerx, layery);
13
- alert(`${lng},${lat}`);
14
- });
15
- var active;
16
- var buttons = ["百度", "谷歌", "OSM", "Default"].map((a, cx) => {
17
- var btn = button(a);
18
- onclick(btn, function () {
19
- if (active) for (var k in active) {
20
- delete map.map[k];
4
+ // center: [/*蒙古*/104.751074, 44.163022],
5
+ // center: [/*西亚*/48.068813, 29.321316],
6
+ zoom: 3
7
+ };
8
+ var page = document.createElement('map-test');
9
+ page.innerHTML = template;
10
+ renderWithDefaults(page, {
11
+ menus: ["高德", "百度", "谷歌", "OSM", { name: "Default", actived: true }].map(a => isObject(a) ? a : { name: a }),
12
+ menu,
13
+ maps: [
14
+ maps$gaode,
15
+ maps$baidu,
16
+ maps$google,
17
+ maps$osm,
18
+ ],
19
+ actived: null,
20
+ locat(event) {
21
+ var map = this.map;
22
+ var layerx = event.offsetX || event.layerX || 0;
23
+ var layery = event.offsetY || event.layerY || 0;
24
+ var [lng, lat] = map.location(layerx, layery);
25
+ alert(`${lng},${lat}`);
26
+ },
27
+ open(m) {
28
+ console.log(m, this.actived)
29
+ for (var k in this.actived) {
30
+ delete this.mp.map[k];
21
31
  }
22
- extend(map.map, active = [
23
- maps$baidu,
24
- maps$google,
25
- maps$osm
26
- ][cx]);
27
- map.map.refresh();
28
- });
29
- return btn;
32
+ extend(this.mp.map, m, { cache: [] });
33
+ this.mp.map.refresh();
34
+ console.log(this.mp.map)
35
+ this.actived = m;
36
+ },
37
+ map() {
38
+ return new maps(config);
39
+ },
30
40
  });
31
- buttons[3].click();
32
- return option(group(buttons), map, 8);
41
+ return page;
33
42
  }
@@ -7,11 +7,9 @@
7
7
  background-position: 0 0, @background-size/2 @background-size/2;
8
8
  height: 200px;
9
9
  }
10
- canvas{
11
- background-color: #035;
12
- }
13
- .button {
14
- height: 40px;
10
+
11
+ canvas {
15
12
  width: 100%;
16
- display: block;
13
+ height: 100%;
14
+ background-color: #035;
17
15
  }
@@ -48,19 +48,20 @@ var getArrayNodes = function (elem) {
48
48
  var nodeName = node.children.length > 1 ? node.children[0].innerHTML : node.innerHTML;
49
49
  deep++;
50
50
  if (nodeName) {
51
- nodes.push({
51
+ nodes.push(new Item({
52
52
  name: nodeName,
53
53
  tab: deep,
54
54
  href: node.getAttribute("path") || node.getAttribute("href"),
55
55
  class: node.className,
56
56
  closed: true
57
- });
57
+ }));
58
58
  }
59
59
  var index = nodes.length - 1;
60
60
  if (node.children.length > 1) {
61
61
  [].forEach.call(node.children[1].children, run);
62
62
  }
63
- nodes[index].children = nodes.splice(index + 1, nodes.length - index);
63
+ nodes[index].push.apply(nodes[index], nodes.splice(index + 1, nodes.length - index));
64
+ nodes[index].children = nodes[index];
64
65
  deep--;
65
66
  };
66
67
  [].forEach.call(elem.children, run);
@@ -93,7 +94,7 @@ var getTreeNodes = function (elem) {
93
94
  var emitEvent = function (item, event) {
94
95
  event.preventDefault(true);
95
96
  if (item.disabled) return;
96
- active(this, item, item, createItemTarget.call(this, item));
97
+ active(this, item, item, this.$src ? createItemTarget.call(this, item) : this);
97
98
  }
98
99
  function bindGlobalkey(elem, keymap, emit) {
99
100
  if (elem.keymap) {
@@ -152,7 +153,7 @@ function main(elem, mode) {
152
153
  tree(elem, function (index, item, menu) {
153
154
  var e = generator(index, item);
154
155
  if (!e || e.children.length) return e;
155
- var m = menuItem(e, menu, elem.useIcon);
156
+ var m = menuItem(null, menu, elem.useIcon);
156
157
  return m;
157
158
  });
158
159
  care(elem, function (data) {
@@ -194,8 +195,8 @@ function main(elem, mode) {
194
195
  case "y":
195
196
  case "vertical":
196
197
  if (!direction) mode = "vertical", direction = 'y';
197
- var emit = function (item) {
198
- active(elem, item.value, item, createItemTarget.call(elem, item.value));
198
+ var emit = function (item, target) {
199
+ active(elem, item, null, elem.$src ? createItemTarget.call(elem, item, target) : target);
199
200
  };
200
201
  if ("$src" in elem) {
201
202
  getGenerator(elem, 'menu-item');
@@ -17,7 +17,7 @@ function main(elem, scope, hasIcon) {
17
17
  else {
18
18
  item.removeAttribute("disabled");
19
19
  }
20
- render(item.children, scope, hasIcon instanceof Array ? hasIcon : [{ useIcon: hasIcon, hasIcon, name, icon }], false);
20
+ render(item.children, scope, hasIcon instanceof Array ? hasIcon : [{ useIcon: hasIcon, hasIcon, name, icon }], 0);
21
21
  if (scope.line) item.setAttribute("line", ''), on("click")(item, preventDefault);
22
22
  if (scope.hotkey) bindAccesskey(item, scope.hotkey);
23
23
  return item;
@@ -231,7 +231,7 @@ function main(page, items, active, direction = 'y') {
231
231
  if (this.menu.line) return;
232
232
  if (byMousedown) return;
233
233
  if (this.hasAttribute("disabled") || this.hasAttribute('line')) return;
234
- var pop = active(this.menu, this);
234
+ var pop = active(this.menu.value, this);
235
235
  if (pop === false) return;
236
236
  var root = page.root || page;
237
237
  if (root.direction === 't' || root.selected) {
@@ -286,6 +286,7 @@ function main(page, items, active, direction = 'y') {
286
286
  };
287
287
  var $scope = {
288
288
  "menu-item"(e, s) {
289
+ if (e && s === e.$scope) s = itemName ? s[itemName] : s.menu;
289
290
  var a = button(
290
291
  menuItem(e, s.value, this.hasIcon)
291
292
  );
@@ -293,10 +294,10 @@ function main(page, items, active, direction = 'y') {
293
294
  page.firstMenu = a;
294
295
  page.total = items.length;
295
296
  }
296
- a.menu = s.menu;
297
+ a.menu = s;
297
298
  return a;
298
299
  },
299
- menus: items,
300
+ menus: items.map(i => i instanceof Item ? i : new Item(i)),
300
301
  hasIcon: hasIcon(),
301
302
  open: fire,
302
303
  cancel,
@@ -315,6 +316,7 @@ function main(page, items, active, direction = 'y') {
315
316
  list(page, function (index) {
316
317
  var item = items[index];
317
318
  if (!item) return;
319
+ if (!(item instanceof Item)) item = new Item(item);
318
320
  var a = $scope["menu-item"](null, item);
319
321
  if (src.itemName) a.setAttribute("e-if", notHidden);
320
322
  a.setAttribute("e-class", className);
@@ -11,6 +11,7 @@ var addDeltaY = function (event) {
11
11
  } else {
12
12
  delta = 120 / (1 - delta / 12) - 120;
13
13
  }
14
+ delta /= devicePixelRatio;
14
15
  if (event.axis === 1) {
15
16
  event.deltaX = delta;
16
17
  event.deltaY = 0;
@@ -395,4 +395,5 @@ var global = function (element, issingle) {
395
395
  };
396
396
  var popup_as_yextra = _as_yextra.bind(null, global, innerWidth, innerHeight);
397
397
  var popup_as_xextra = _as_xextra.bind(null, global, innerHeight, innerWidth);
398
- var cleanup = new Cleanup(rootElements);
398
+ var cleanup = new Cleanup(rootElements);
399
+ popup.style = animationStyle;
@@ -1,17 +1,26 @@
1
1
  var hasOwnProperty = {}.hasOwnProperty;
2
2
  var renderElements = Object.create(null);
3
3
  var presets = Object.create(null);
4
+ var createTemplateNodes = function (text) {
5
+ var node = document.createElement(this.parentNode.tagName || "div");
6
+ node.innerHTML = text;
7
+ remove(this.with);
8
+ this.with = [].slice.call(node.childNodes, 0);
9
+ appendChild.after(this, this.with);
10
+ renderElement(this.with, this.$scope, this.$parentScopes, this.renderid === 9);
11
+ };
4
12
  presets.template = function (t) {
5
13
  var comment = document.createComment('template');
6
14
  comment.$scope = t.$scope;
7
15
  comment.$parentScopes = t.$parentScopes;
8
- once("append")(comment, function () {
9
- var node = document.createElement(comment.parentNode.tagName || "div");
10
- node.innerHTML = t.innerHTML;
11
- comment.with = [].slice.call(node.childNodes, 0);
12
- appendChild.after(comment, comment.with);
13
- renderElement(comment.with, comment.$scope, comment.$parentScopes, this.renderid === 9);
14
- });
16
+ if (!t.innerHTML) {
17
+ care(comment, createTemplateNodes)
18
+ }
19
+ else {
20
+ once("append")(comment, function () {
21
+ createTemplateNodes.call(comment, t.innerHTML);
22
+ });
23
+ }
15
24
  return comment;
16
25
  };
17
26
  window.renderElements = renderElements;
@@ -81,6 +90,8 @@ var createGetter = function (search, isprop = true) {
81
90
  var initialComment = function (renders, type, expression) {
82
91
  var comment = document.createComment(`${type} ${expression}`);
83
92
  comment.renders = renders;
93
+ comment.$scope = this.$scope;
94
+ comment.$parentScopes = this.$parentScopes;
84
95
  appendChild.after(this, comment);
85
96
  if (!/if/i.test(type)) remove(this);
86
97
  if (!this.$struct.once) {
@@ -183,7 +194,6 @@ var createRepeat = function (search, id = 0) {
183
194
  clone.$scope = $scope;
184
195
  clone.$parentScopes = $parentScopes;
185
196
  clone.$struct = $struct;
186
- clone = render(clone, $scope, clone.$parentScopes);
187
197
  clonedElements1[k] = clone;
188
198
  return clone;
189
199
  }, this);
@@ -192,6 +202,7 @@ var createRepeat = function (search, id = 0) {
192
202
  if (a.previousSibling !== last) appendChild.after(last, a);
193
203
  last = a;
194
204
  }, this);
205
+ cloned.forEach(a => render(a))
195
206
  for (var k in clonedElements) {
196
207
  if (clonedElements1[k] !== clonedElements[k]) remove(clonedElements[k]);
197
208
  }
@@ -682,7 +693,9 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
682
693
  }
683
694
  });
684
695
  replacer.renderid = element.renderid;
685
- replacer.renders = element.renders;
696
+ var renders = element.renders;
697
+ if (replacer.renders) renders = renders.concat(replacer.renders);
698
+ replacer.renders = renders;
686
699
  if (binds.src) replacer.$src = element.$src;
687
700
  element = replacer;
688
701
  element.$scope = scope;
@@ -692,6 +705,8 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
692
705
  }
693
706
  if (element.children && element.children.length) renderElement(element.children, scope, parentScopes, once);
694
707
  if (!isFirstRender) return element;
708
+ var renders = element.renders;
709
+ element.renders = [];
695
710
  for (var k in binds) {
696
711
  if (directives.hasOwnProperty(k)) {
697
712
  directives[k].call(element, [withContext, binds[k]])
@@ -709,6 +724,7 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
709
724
  } catch (e) { }
710
725
  }
711
726
  ons.forEach(([on, key, value]) => on.call(element, key, [withContext, value]));
727
+ if (renders.length) element.renders.push.apply(element.renders, renders);
712
728
  if (element.renders.length) {
713
729
  if (element.renderid !== 9) {
714
730
  onmounted(element, addRenderElement);
@@ -224,7 +224,7 @@ function tree() {
224
224
  _div.refresh();
225
225
  onclick(_div, function (event) {
226
226
  var isClosed = com.isClosed();
227
- if (!active(banner, com.value, com, element.$src ? createItemTarget.call(element, com.value) : _div)) {
227
+ if (!active(banner, com.value, com, banner.$src ? createItemTarget.call(banner, com.value) : _div)) {
228
228
  return;
229
229
  }
230
230
  if (isClosed === com.isClosed() && com.length) {
@@ -127,7 +127,13 @@ function go(pagepath, args, history_name, oldpagepath) {
127
127
  } else {
128
128
  var { roles, options, id } = getZimoliParams(pagepath);
129
129
  }
130
- if (!pagepath) return true;
130
+ if (!pagepath) {
131
+ if (isNode(history_name)) {
132
+ remove(history_name.activateNode);
133
+ history_name.activate = pagepath;
134
+ }
135
+ return true;
136
+ }
131
137
  setZimoliParams(pagepath, { data: args, from: oldpagepath, options, roles, id });
132
138
  prepare(pagepath, function (res) {
133
139
  if (!res.roles || res.roles === true) res.roles = !!roles;
@@ -594,7 +600,11 @@ function addGlobal(element, name = null, isDestroy) {
594
600
  }
595
601
  global[name] = element;
596
602
  } else if (isNode(name)) {
597
- if (isDestroy) appendChild.insert(name, element);
603
+ if (name.nodeType !== 1) {
604
+ appendChild.after(name, element);
605
+ name.with = [element];
606
+ }
607
+ else if (isDestroy) appendChild.insert(name, element);
598
608
  else appendChild(name, element);
599
609
  } else if (isFunction(name)) {
600
610
  name(element);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.18.0",
3
+ "version": "3.18.3",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {