efront 3.26.7 → 3.26.14

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.
Files changed (66) hide show
  1. package/apps/index.jsp +2 -2
  2. package/apps/pivot/dht/list.js +53 -0
  3. package/apps/pivot/index.html +3 -1
  4. package/apps/pivot/main.js +1 -0
  5. package/apps/pivot/main.less +3 -0
  6. package/apps/pivot/wow/root.js +138 -104
  7. package/apps/pivot/wow/root.less +1 -62
  8. package/coms/basic/Task.js +51 -0
  9. package/coms/basic/cross_.js +8 -0
  10. package/coms/basic/keys.js +3 -4
  11. package/coms/basic/loader.js +42 -17
  12. package/coms/basic/submit_.js +6 -3
  13. package/coms/explorer/Explorer.js +85 -0
  14. package/coms/explorer/context.js +205 -0
  15. package/coms/explorer/deepcp.js +48 -0
  16. package/{apps/pivot/wow → coms/explorer}/edit.html +1 -1
  17. package/{apps/pivot/wow → coms/explorer}/edit.js +17 -9
  18. package/coms/explorer/fileitem.html +8 -0
  19. package/coms/explorer/fileitem.js +34 -0
  20. package/coms/explorer/fileitem.less +65 -0
  21. package/coms/explorer/filetip.js +10 -0
  22. package/coms/explorer/filetip.less +5 -0
  23. package/coms/explorer/main.html +8 -0
  24. package/coms/explorer/main.js +215 -0
  25. package/coms/explorer/main.less +78 -0
  26. package/coms/frame/route.js +1 -1
  27. package/coms/shapes/file.html +9 -0
  28. package/coms/shapes/folder.html +7 -0
  29. package/coms/zimoli/Cleanup.js +9 -8
  30. package/coms/zimoli/arriswise.js +5 -4
  31. package/coms/zimoli/attr.js +2 -0
  32. package/coms/zimoli/bindGlobalkey.js +37 -0
  33. package/coms/zimoli/confirm.js +8 -8
  34. package/coms/zimoli/confirm.less +6 -80
  35. package/coms/zimoli/container.js +19 -6
  36. package/coms/zimoli/contextmenu.js +35 -15
  37. package/coms/zimoli/drag.js +7 -3
  38. package/coms/zimoli/field.html +1 -1
  39. package/coms/zimoli/field.js +8 -2
  40. package/coms/zimoli/field.less +0 -1
  41. package/coms/zimoli/getChanges.js +1 -0
  42. package/coms/zimoli/list.js +44 -33
  43. package/coms/zimoli/menu.js +1 -24
  44. package/coms/zimoli/menuItem.html +4 -1
  45. package/coms/zimoli/menuList.js +54 -104
  46. package/coms/zimoli/menuList.less +1 -0
  47. package/coms/zimoli/moveupon.js +2 -2
  48. package/coms/zimoli/overpos.js +7 -0
  49. package/coms/zimoli/popup.js +22 -27
  50. package/coms/zimoli/prompt.js +43 -5
  51. package/coms/zimoli/prompt.less +23 -0
  52. package/coms/zimoli/render.js +155 -109
  53. package/coms/zimoli/resize.js +12 -5
  54. package/coms/zimoli/rootElements.js +15 -1
  55. package/coms/zimoli/view.js +33 -0
  56. package/coms/zimoli/view.less +8 -8
  57. package/coms/zimoli/yousure.js +53 -0
  58. package/coms/zimoli/yousure.less +4 -0
  59. package/coms/zimoli/zimoli.js +10 -6
  60. package/package.json +1 -1
  61. package/public/efront.js +1 -1
  62. package/apps/pivot/wow/root.html +0 -10
  63. package/coms/zimoli/explorer.html +0 -5
  64. package/coms/zimoli/explorer.js +0 -8
  65. package/coms/zimoli/explorer.less +0 -18
  66. package/coms/zimoli/explorer_test.js +0 -4
@@ -0,0 +1,23 @@
1
+ tip {
2
+ display: block;
3
+ font-size: 12px;
4
+ color: #c24;
5
+ }
6
+
7
+ [error] {
8
+
9
+ >input {
10
+ background: #c241;
11
+ border-color: #c24;
12
+ }
13
+ }
14
+
15
+ textarea {
16
+ width: 100%;
17
+ height: 100%;
18
+ resize: none;
19
+ }
20
+
21
+ input {
22
+ width: 100%;
23
+ }
@@ -2,10 +2,28 @@ var hasOwnProperty = {}.hasOwnProperty;
2
2
  var renderElements = Object.create(null);
3
3
  var presets = Object.create(null);
4
4
  var createTemplateNodes = function (text) {
5
- var node = document.createElement(this.parentNode.tagName || "div");
6
- node.innerHTML = text;
7
5
  remove(this.with);
8
- this.with = [].slice.call(node.childNodes, 0);
6
+ if (isEmpty(text)) return;
7
+ if (isNode(text)) {
8
+ var node = text;
9
+ if (isElement(node) && this.$struct.copys) {
10
+ for (var c of this.$struct.copys) {
11
+ if (c.name === 'class') {
12
+ addClass(node, c.value);
13
+ }
14
+ else if (c.name === 'style') {
15
+ css(node, c.value);
16
+ }
17
+ else node.setAttribute(c.name, c.value);
18
+ }
19
+ }
20
+ this.with = [node];
21
+ return;
22
+ } else {
23
+ var node = document.createElement(this.parentNode.tagName || "div");
24
+ node.innerHTML = text;
25
+ this.with = [].slice.call(node.childNodes, 0);
26
+ }
9
27
  appendChild.after(this, this.with);
10
28
  this.with = renderElement(this.with, this.$scope, this.$parentScopes, this.renderid === 9);
11
29
  };
@@ -13,7 +31,7 @@ presets.template = function (t) {
13
31
  var comment = document.createComment('template');
14
32
  comment.$scope = t.$scope;
15
33
  comment.$parentScopes = t.$parentScopes;
16
- if (!t.innerHTML) {
34
+ if (t.$struct.binds.src) {
17
35
  care(comment, createTemplateNodes)
18
36
  }
19
37
  else {
@@ -77,20 +95,13 @@ function rebuild(element) {
77
95
  }
78
96
  }
79
97
  var variableReg = /([^\:\,\+\=\-\!%\^\|\/\&\*\!\;\?\>\<~\{\}\s\[\]\(\)]|\?\s*\.(?=[^\d])|\s*\.\s*)+/g;
80
- var createGetter = function (search, isprop = true) {
98
+ var variableOnlyReg = new RegExp(`^${variableReg.source}$`);
99
+ var createGetter = function (target, search, isprop = true) {
81
100
  if (!search) return function () { };
82
101
  search = renderExpress(search);
83
- if (isprop) {
84
- return function (event) {
85
- return $eval.call(this, search, this.$scope, event);
86
- };
87
- }
88
- if (/([\=\(\+\-])/.test(search)) return function (event) {
89
- return $eval.call(this, search, this.$scope, event);
90
- }
91
- else return function (event) {
92
- $eval.call(this, search)(event);
93
- }
102
+ if (isprop) return $$eval.bind(target, search, null);
103
+ if (variableOnlyReg.test(search)) return $$eval.bind(target, search + "(event)", null);
104
+ else return $$eval.bind(target, search, null);
94
105
  };
95
106
  var createComment = function (renders, type, expression) {
96
107
  var comment = document.createComment(`${type} ${expression}`);
@@ -187,11 +198,11 @@ var createRepeat = function (search, id = 0) {
187
198
  if (!repeater) throw new Error(`不能识别循环表达式: ${expression} `);
188
199
  var { srcName, trackBy } = repeater;
189
200
  // 懒渲染
190
- var getter = createGetter(srcName).bind(this);
201
+ var getter = createGetter(this, srcName);
191
202
  var element = this, clonedElements = [], savedValue, savedOrigin;
192
203
  if (this.$struct.if) id = -7;
193
204
  var renders = [function () {
194
- var result = getter();
205
+ var result = getter(this);
195
206
  var origin = result;
196
207
  result = extend(result instanceof Array ? [] : {}, result);
197
208
  if (savedOrigin === origin && deepEqual.shallow(savedValue, result)) return;
@@ -260,7 +271,7 @@ var initIf = function (ifs) {
260
271
  };
261
272
  var createIf = function (search, id = 0) {
262
273
  // 懒渲染
263
- var getter = createGetter(search).bind(this);
274
+ var getter = createGetter(this, search);
264
275
  var element = this;
265
276
  var elements = [element, getter];
266
277
  if_top.push(elements);
@@ -268,15 +279,17 @@ var createIf = function (search, id = 0) {
268
279
  elements.parent = this.parentNode;
269
280
  elements.comment = search;
270
281
  if (this.$struct.repeat) id = -3;
282
+
271
283
  elements.renders = [function () {
272
284
  var shouldMount = -1;
273
285
  for (var cx = 0, dx = elements.length; cx < dx; cx += 2) {
274
286
  var getter = elements[cx + 1];
275
- if (!getter || getter()) {
287
+ if (!getter || getter(this)) {
276
288
  shouldMount = cx;
277
289
  break;
278
290
  }
279
291
  }
292
+ // console.log(shouldMount,savedValue,this,this.$scope)
280
293
  if (savedValue === shouldMount) return;
281
294
  savedValue = shouldMount;
282
295
  for (var cx = 0, dx = elements.length; cx < dx; cx += 2) {
@@ -366,17 +379,20 @@ var renderStructure = function (element) {
366
379
  var $struct = element.$struct;
367
380
  if ($struct.if) var { name: ifkey, key, value: ifexp } = $struct.if;
368
381
  if ($struct.repeat) var { value: repeat } = $struct.repeat;
369
- delete $struct.if;
370
382
  if (!ifkey) return createRepeat.call(element, repeat);
371
383
  if (!ifexp || !repeat) return structures[key].call(element, ifexp);
372
384
  var { before, after } = parseIfWithRepeat(ifexp, repeat);
373
385
  if (after.length) {
374
386
  $struct.if = { key, name: ifkey, value: after.join("&&") };
375
387
  }
388
+ else {
389
+ delete $struct.if;
390
+ }
376
391
  if (before.length > 0) {
377
392
  return createIf.call(element, before.join("&&"), null);
378
393
  } else {
379
394
  delete $struct.repeat;
395
+ if (!repeat) debugger;
380
396
  return createRepeat.call(element, repeat, null);
381
397
  }
382
398
  };
@@ -396,7 +412,7 @@ var structures = {
396
412
  initIf(if_top.splice(cx + 1, if_top.length - cx - 1));
397
413
  var top = if_top[cx];
398
414
  if (search && search) {
399
- var getter = createGetter(search).bind(this);
415
+ var getter = createGetter(this, search);
400
416
  }
401
417
  var comment = createComment.call(this, undefined, search ? 'elseif' : 'else', search);
402
418
  top.push(comment, getter);
@@ -409,10 +425,10 @@ structures["else-if"] = structures.elseif = structures.else;
409
425
  structures["for-each"] = structures.foreach = structures.for = structures.each = structures.repeat;
410
426
  var createBinder = function (binder) {
411
427
  return function (search) {
412
- var getter = createGetter(`(${search})`).bind(this);
428
+ var getter = createGetter(this, `(${search})`);
413
429
  var oldValue;
414
430
  this.renders.push(function () {
415
- var value = getter();
431
+ var value = getter(this);
416
432
  if (deepEqual.shallow(value, oldValue)) return;
417
433
  oldValue = value;
418
434
  if (isNode(value) || isArray(value)) {
@@ -430,10 +446,10 @@ var createBinder = function (binder) {
430
446
  }
431
447
 
432
448
  var src2 = function (search) {
433
- var getter = createGetter(search).bind(this);
449
+ var getter = createGetter(this, search);
434
450
  var savedValue;
435
451
  this.renders.push(function () {
436
- var origin = getter();
452
+ var origin = getter(this);
437
453
  var temp = origin;
438
454
  if (origin instanceof Array) {
439
455
  temp = extend([], origin);
@@ -465,36 +481,36 @@ var directives = {
465
481
  var parsedSrc = this.$src;
466
482
  return src2.call(this, parsedSrc ? parsedSrc.srcName : src);
467
483
  },
468
- model(search) {
469
- var getter = createGetter(search).bind(this);
484
+ model(search, target) {
485
+ var getter = createGetter(this, search);
470
486
  var oldValue;
471
- var getstr = this.getValue instanceof Function ? "this.getValue()" : "";
472
- var setter = this.setValue instanceof Function ? function () {
473
- var value = getter();
487
+ var getstr = target.getValue instanceof Function ? "this.getValue()" : "";
488
+ var setter = target.setValue instanceof Function ? function () {
489
+ var value = getter(this);
474
490
  if (value === undefined) value = "";
475
491
  if (deepEqual(oldValue, value)) return;
476
492
  oldValue = value;
477
493
  this.setValue(value);
478
494
  } : null;
479
495
  var setter2 = function (key) {
480
- var value = getter();
496
+ var value = getter(this);
481
497
  if (value === undefined) value = "";
482
498
  if (deepEqual(oldValue, value)) return;
483
499
  oldValue = value;
484
500
  this[key] = value;
485
501
  };
486
- if (/^input$/i.test(this.tagName) && /^checkbox$/i.test(this.type) || /^checkbox$/i.test(this.tagName)) {
487
- this.renders.push(setter || setter2.bind(this, 'checked'));
502
+ if (/^input$/i.test(target.tagName) && /^checkbox$/i.test(target.type) || /^checkbox$/i.test(target.tagName)) {
503
+ this.renders.push(setter || setter2.bind(target, 'checked'));
488
504
  var change = getstr || "this.checked";
489
- } else if (("value" in this || this.getValue instanceof Function) && this.setValue instanceof Function) {
505
+ } else if (("value" in target || target.getValue instanceof Function) && target.setValue instanceof Function) {
490
506
  this.renders.push(setter);
491
507
  var change = getstr || "this.value";
492
- } else if (/^(select|input|textarea)$/i.test(this.tagName) || "value" in this) {
493
- this.renders.push(setter || setter2.bind(this, 'value'));
508
+ } else if (/^(select|input|textarea)$/i.test(target.tagName) || "value" in target) {
509
+ this.renders.push(setter || setter2.bind(target, 'value'));
494
510
  var change = getstr || "this.value";
495
511
  } else {
496
512
  this.renders.push(setter || function () {
497
- var value = getter();
513
+ var value = getter(this);
498
514
  if (value === undefined) value = "";
499
515
  if (deepEqual(oldValue, value)) return;
500
516
  oldValue = value;
@@ -503,24 +519,25 @@ var directives = {
503
519
  var change = getstr || "'value' in this?this.value:this.innerHTML";
504
520
  }
505
521
  setter2 = null;
522
+ var changeme = $$eval.bind(this, search + "=" + change, null);
506
523
  var onchange = function () {
507
- $eval.call(this, search + "=" + change, this.$scope);
508
- var value = getter();
524
+ changeme(this);
525
+ var value = getter(this);
509
526
  if (value === oldValue) {
510
527
  return;
511
528
  }
512
529
  oldValue = value;
513
530
  userChanged = true;
514
531
  };
515
- eventsBinders.forEach(on => on(this, onchange, true));
532
+ eventsBinders.forEach(on => on(target, onchange, true));
516
533
  },
517
534
 
518
535
  "class"(search) {
519
- var getter = createGetter(`(${search})`).bind(this);
536
+ var getter = createGetter(this, `(${search})`);
520
537
  var generatedClassNames = {};
521
538
  var oldValue;
522
539
  this.renders.push(function () {
523
- var className = getter();
540
+ var className = getter(this);
524
541
  if (deepEqual(oldValue, className)) return;
525
542
  oldValue = className;
526
543
  var originalClassNames = [];
@@ -556,10 +573,10 @@ directives.text = directives.bind;
556
573
  var binders = {
557
574
  _(attr, search) {
558
575
  attr = attr.replace(/\-(\w)/g, (_, w) => w.toUpperCase());
559
- var getter = createGetter(search).bind(this);
576
+ var getter = createGetter(this, search);
560
577
  var oldValue;
561
578
  this.renders.push(function () {
562
- var value = getter();
579
+ var value = getter(this);
563
580
  if (deepEqual(value, oldValue)) return;
564
581
  oldValue = value;
565
582
  if (this[attr] !== value) {
@@ -568,10 +585,10 @@ var binders = {
568
585
  });
569
586
  },
570
587
  ""(attr, search) {
571
- var getter = createGetter(search).bind(this);
588
+ var getter = createGetter(this, search);
572
589
  var oldValue;
573
590
  this.renders.push(function () {
574
- var value = getter();
591
+ var value = getter(this);
575
592
  if (deepEqual(value, oldValue)) return;
576
593
  oldValue = value;
577
594
  if (value === true || value === '') {
@@ -587,10 +604,12 @@ var binders = {
587
604
  }
588
605
  };
589
606
  var reject = function (e) { digest(); throw e };
590
- var createEmiter = function (on) {
591
- return function (key, search) {
592
- var parsedSrc = this.$src;
593
- var getter = createGetter(search, false);
607
+ var createEmiter = function (on, target) {
608
+ return function (target, key, search) {
609
+ /**
610
+ * @type {Repeater}
611
+ */
612
+ var getter = createGetter(this, search, false);
594
613
  var onkey;
595
614
  if (key === 'mounted' || key === 'mount') {
596
615
  onkey = on === once ? oncemount : onmounted;
@@ -601,18 +620,24 @@ var createEmiter = function (on) {
601
620
  else {
602
621
  onkey = on(key);
603
622
  }
604
- onkey(this, function (e) {
623
+ onkey(target, function (e) {
605
624
  digest();
606
- if (parsedSrc) {
607
- var target = e.currentTarget || e.target;
608
- var scopes = target && target.$parentScopes;
609
- if (scopes) {
610
- var scope = null;
611
- for (var cx = scopes.length - 1; cx >= 0; cx--) {
612
- var s = scopes[cx];
613
- if (s === this.$scope) {
614
- scope = scopes[cx + 1];
615
- break;
625
+ var parsedSrc = this.$src;
626
+ if (parsedSrc instanceof Repeater) {
627
+ var target = e.currentTarget === this ? e.target : e.currentTarget || e.target;
628
+ if (target === this) {
629
+ scope = parsedSrc.createScope();
630
+ }
631
+ else {
632
+ var scopes = target && target.$parentScopes;
633
+ if (scopes) {
634
+ var scope = null;
635
+ for (var cx = scopes.length - 1; cx >= 0; cx--) {
636
+ var s = scopes[cx];
637
+ if (s === this.$scope) {
638
+ scope = scopes[cx + 1];
639
+ break;
640
+ }
616
641
  }
617
642
  }
618
643
  }
@@ -623,12 +648,12 @@ var createEmiter = function (on) {
623
648
  var temp = this.$scope;
624
649
  this.$parentScopes.push(temp);
625
650
  this.$scope = scope;
626
- res = getter.call(this, e);
651
+ res = getter(this, e);
627
652
  this.$parentScopes.pop();
628
653
  this.$scope = temp;
629
654
  }
630
655
  else {
631
- res = getter.call(this, e);
656
+ res = getter(this, e);
632
657
  }
633
658
  if (res && isFunction(res.then)) res.then(digest, reject);
634
659
  return res;
@@ -656,6 +681,31 @@ function getFromScopes(key, scope, parentScopes) {
656
681
  }
657
682
  }
658
683
 
684
+ function renderRest(element, struct, replacer = element) {
685
+ var renders = element.renders;
686
+ element.renders = [];
687
+ var { binds, attrs, props } = struct;
688
+ for (var k in binds) {
689
+ if (k === 'src') continue;
690
+ if (directives.hasOwnProperty(k)) {
691
+ directives[k].call(element, binds[k], replacer);
692
+ }
693
+ else {
694
+ binders._.call(element, k, binds[k]);
695
+ }
696
+ }
697
+ for (var k in struct.attrs) {
698
+ binders[""].call(element, k, attrs[k]);
699
+ }
700
+ for (var k in struct.props) {
701
+ try {
702
+ if (replacer[k] !== props[k]) replacer[k] = props[k];
703
+ } catch (e) { }
704
+ }
705
+ if (binds.src) directives.src.call(element, binds.src);
706
+ if (renders.length) element.renders.push.apply(element.renders, renders);
707
+ }
708
+
659
709
  function renderElement(element, scope = element.$scope, parentScopes = element.$parentScopes, once) {
660
710
  if (isArrayLike(element)) {
661
711
  return Array.prototype.slice.call(element).map(function (element) {
@@ -687,13 +737,11 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
687
737
  if (!element || element.renderid < 0 || element.nodeType !== 1) {
688
738
  return element;
689
739
  }
690
- var elementid = element.getAttribute("renderid") || element.getAttribute("elementid") || element.getAttribute("id");
691
- if (elementid) {
692
- if (scope[elementid] && scope[elementid] !== element) throw new Error("同一个id不能使用两次:" + elementid);
693
- scope[elementid] = element;
740
+ for (var id of element.$struct.ids) {
741
+ if (scope[id] && scope[id] !== element) throw new Error("同一个id不能使用两次:" + id);
742
+ scope[id] = element;
694
743
  }
695
744
  var isFirstRender = !element.renderid;
696
-
697
745
  if (isFirstRender) {
698
746
  element.renderid = 1;
699
747
  var parentNode = element.parentNode;
@@ -701,7 +749,7 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
701
749
  if (parentNode.renderid > 1 || isMounted(parentNode)) element.renderid = 2;
702
750
  }
703
751
  element.renders = element.renders ? [].concat(element.renders) : [];
704
- var { ons, copys, attrs, props, binds, ids, once } = element.$struct;
752
+ var { copys, binds, once } = element.$struct;
705
753
  if (once) element.renderid = 9;
706
754
  if (binds.src) {
707
755
  element.$src = parseRepeat(binds.src);
@@ -720,6 +768,11 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
720
768
  if (isFunction(constructor)) {
721
769
  var replacer = constructor.call(scope, element, scope, parentScopes);
722
770
  if (isNode(replacer) && element !== replacer) {
771
+ if (!replacer.$scope) {
772
+ replacer.$scope = scope;
773
+ }
774
+ if (replacer.children && replacer.children.length) renderElement(replacer.children, replacer.$scope, replacer.$parentScopes || parentScopes, once);
775
+ if (!replacer.$parentScopes) replacer.$parentScopes = parentScopes;
723
776
  if (nextSibling) appendChild.before(nextSibling, replacer);
724
777
  else if (parentNode) appendChild(parentNode, replacer);
725
778
  if (element.parentNode === parentNode) remove(element);
@@ -740,42 +793,29 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
740
793
  replacer.setAttribute(name, value);
741
794
  }
742
795
  });
743
- replacer.renderid = element.renderid;
744
- var renders = element.renders;
745
- if (replacer.renders) renders = renders.concat(replacer.renders);
746
- replacer.renders = renders;
747
- if (binds.src) replacer.$src = element.$src;
748
- replacer.$eval = element.$eval;
749
- element = replacer;
750
- element.$scope = scope;
751
- element.$parentScopes = parentScopes;
796
+ if (!replacer.renderid) replacer.renderid = element.renderid;
752
797
  }
753
798
  }
754
799
  }
755
- if (element.children && element.children.length) renderElement(element.children, scope, parentScopes, once);
800
+ if (!replacer || element === replacer) {
801
+ if (element.children && element.children.length) renderElement(element.children, scope, parentScopes, once);
802
+ }
756
803
  if (!isFirstRender) return element;
757
- var renders = element.renders;
758
- element.renders = [];
759
- for (var k in binds) {
760
- if (k === 'src') continue;
761
- if (directives.hasOwnProperty(k)) {
762
- directives[k].call(element, binds[k])
804
+ renderRest(element, element.$struct, replacer);
805
+ if (replacer) {
806
+ if (!replacer.renders) replacer.renders = [];
807
+ if (isElement(replacer)) createStructure(replacer);
808
+ replacer.renders = [].concat(element.renders, replacer.renders);
809
+ for (var id of element.$struct.ids) {
810
+ scope[id] = replacer;
763
811
  }
764
- else {
765
- binders._.call(element, k, binds[k]);
812
+ if (replacer.$struct && replacer.$struct !== element.$struct) {
813
+ renderRest(replacer, replacer.$struct);
814
+ element.$struct.ons.forEach(([on, key, value]) => on.call(element, replacer, key, value));
766
815
  }
816
+ element = replacer;
767
817
  }
768
- for (var k in attrs) {
769
- binders[""].call(element, k, attrs[k]);
770
- }
771
- for (var k in props) {
772
- try {
773
- if (element[k] !== props[k]) element[k] = props[k];
774
- } catch (e) { }
775
- }
776
- if (binds.src) directives.src.call(element, binds.src);
777
- ons.forEach(([on, key, value]) => on.call(element, key, value));
778
- if (renders.length) element.renders.push.apply(element.renders, renders);
818
+ if (element.$struct) element.$struct.ons.forEach(([on, key, value]) => on.call(element, element, key, value));
779
819
  if (element.renders.length) {
780
820
  if (element.renderid !== 9) {
781
821
  onmounted(element, addRenderElement);
@@ -787,21 +827,18 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
787
827
  rebuild(element);
788
828
  }
789
829
  }
790
- if (elementid) scope[elementid] = element;
791
- for (var id of ids) {
792
- scope[id] = element;
793
- }
794
830
  return element;
795
831
  }
796
832
  var createEval = function (deep) {
797
833
  var context = [];
798
834
  while (deep-- > 0) {
799
- context[deep] = `with(this.$parentScopes[${deep}])`;
835
+ context[deep] = `with($parentScopes[${deep}])`;
800
836
  }
801
- return new Function("code", "event", `${context.join('')}with(this.$scope)return eval(code)`);
837
+ return new Function("$parentScopes", "$scope", "code", "event", `${context.join('')}with($scope)return eval(code)`);
802
838
  };
803
839
  var evalcontexts = [createEval(0)];
804
- function $eval(search, scope, event) {
840
+
841
+ function $$eval(search, scope, target = this, event) {
805
842
  var needpop = scope && scope !== this.$scope;
806
843
  if (needpop) {
807
844
  this.$parentScopes.push(this.$scope);
@@ -810,11 +847,15 @@ function $eval(search, scope, event) {
810
847
  var length = this.$parentScopes ? this.$parentScopes.length : 0;
811
848
  if (!evalcontexts[length]) evalcontexts[length] = createEval(length);
812
849
  var eval2 = evalcontexts[length];
813
- var res = eval2.call(this, search, event);
850
+ var res = eval2.call(target, this.$parentScopes, this.$scope, search, event);
814
851
  if (needpop) this.$scope = this.$parentScopes.pop();
815
852
  return res;
816
853
  }
817
854
 
855
+ function $eval(search, scope, event) {
856
+ return $$eval.call(this, search, scope, this, event);
857
+ }
858
+
818
859
  class Struct {
819
860
  constructor(ons, types, copys, binds, attrs, props, ids, once) {
820
861
  this.ons = ons;
@@ -834,6 +875,7 @@ function createStructure(element) {
834
875
  if (isArrayLike(element)) return Array.prototype.map.call(element, createStructure);
835
876
  if (element.$struct) return element.$struct;
836
877
  // 处理结构流
878
+ if (!element.attributes) console.log(element)
837
879
  var attrs = Array.prototype.slice.call(element.attributes);
838
880
  var types = {};
839
881
  var emiter_reg = /^(?:(v|ng|on|once)?\-|v\-on\:|@|once|on)/i;
@@ -846,6 +888,10 @@ function createStructure(element) {
846
888
  var ids = [];
847
889
  for (var attr of attrs) {
848
890
  var { name, value } = attr;
891
+ if (name === 'elementid' || name === 'renderid' || name === 'id') {
892
+ ids.push(value);
893
+ continue;
894
+ }
849
895
  if (/^#/.test(name)) {
850
896
  ids.push(name.slice(1));
851
897
  element.removeAttribute(name);
@@ -940,9 +986,9 @@ function render(element, scope, parentScopes, lazy = true) {
940
986
  var digest = lazy(refresh, -{});
941
987
  render.digest = render.apply = render.refresh = digest;
942
988
  render.parseRepeat = parseRepeat;
943
- var eventsBinders = "fullscreenchange,resize,load,change,click,paste,resize,keydown,keypress,keyup,input,drop".split(",").map(k => on(k));
989
+ "fullscreenchange,resize,load,hashchange".split(",").forEach(e => on(e)(window, digest));
990
+ var eventsBinders = "change,click,paste,cut,resize,keydown,keypress,keyup,input,drop".split(",").map(k => on(k));
944
991
  var userChanged = false;
945
- eventsBinders.splice(0, 3).forEach(on => on(window, digest));
946
992
  var changeListener = function () {
947
993
  if (userChanged) {
948
994
  userChanged = false;
@@ -52,10 +52,16 @@ var handle = {
52
52
  if (dragging) return;
53
53
  dragging = getResizer(event);
54
54
  if (!dragging) return;
55
- event.moveLocked = true;
56
55
  var elem = dragging.rect;
57
56
  if (elem.offsetParent && /^(absolute|fixed|relative)$/i.test(getComputedStyle(elem.offsetParent).position)) {
58
- var pos = getScreenPosition(elem.offsetParent);
57
+ var parent = elem.offsetParent;
58
+ var pos = getScreenPosition(parent);
59
+ pos.left += parent.clientLeft;
60
+ pos.top += parent.clientTop;
61
+ pos.right = parent.clientWidth + pos.left;
62
+ pos.bottom = parent.clientHeight + pos.top;
63
+ pos.width = parent.clientWidth;
64
+ pos.height = parent.clientHeight;
59
65
  } else {
60
66
  var pos = {
61
67
  left: 0,
@@ -88,8 +94,6 @@ var handle = {
88
94
  },
89
95
  move(event) {
90
96
  if (!dragging) return;
91
- if (event.moveLocked) return;
92
- event.moveLocked = true;
93
97
  var limit = dragging.limit;
94
98
  var { clientX, clientY } = event;
95
99
  var [minx, miny, maxx, maxy] = limit;
@@ -130,8 +134,11 @@ var handle = {
130
134
  dragging = null;
131
135
  }
132
136
  };
133
- function resize(elem, initialEvent) {
137
+ function resize(elem, initialEvent, limit = elem.limit) {
138
+ resizingElements.push(elem);
134
139
  moveupon(elem, handle, initialEvent);
140
+ if (limit && dragging) extendIfOccurs(dragging.limit, limit);
141
+ resizingElements.pop();
135
142
  }
136
143
  moveupon(window, handle);
137
144
 
@@ -37,4 +37,18 @@ rootElements.unmount = function (elem) {
37
37
  if (!elem.parentNode) return;
38
38
  rootElements.pop(elem);
39
39
  remove(elem);
40
- };
40
+ };
41
+ /**
42
+ * 弹出层
43
+ */
44
+ on("keydown.esc.only")(document, function (e) {
45
+ if (e.defaultPrevented) return;
46
+ if (rootElements.length) {
47
+ var r = rootElements.pop();
48
+ if (r) {
49
+ r.blur();
50
+ remove(r);
51
+ e.preventDefault();
52
+ }
53
+ }
54
+ });
@@ -90,6 +90,37 @@ var init = function () {
90
90
  marginRight: -getScrollbarWidth() + "px"
91
91
  });
92
92
  };
93
+ var isType = function (target, type) {
94
+ // 记得小时候,不论是苍蝇还是蚊子,飞起来都是有声音的。最近看到的一种像蚊子一样小的飞虫,喜欢像苍蝇一样趴在食物上,飞起来却听不到声音。
95
+ // 是我的听力下降了?还是外界太过嘈杂?还是飞虫拍打翅膀的频率超出了我的听觉范围?还是飞行可以不产生声音?
96
+ return target.hasAttribute(type) || hasClass(type);
97
+ }
98
+ var resize2 = function () {
99
+ var head, body, foot;
100
+ for (var c of this.children) {
101
+ if (isType(c, "head")) head = c;
102
+ else if (isType(c, "body")) body = c;
103
+ else if (isType(c, "foot")) foot = c;
104
+ }
105
+ if (head && body) {
106
+ var height = head.offsetHeight;
107
+ css(head, {
108
+ marginBottom: fromOffset(-height),
109
+ })
110
+ css(body, {
111
+ paddingTop: fromOffset(height)
112
+ });
113
+ }
114
+ if (foot && body) {
115
+ var height = foot.offsetHeight;
116
+ css(body, {
117
+ paddingBottom: fromOffset(height)
118
+ });
119
+ css(foot, {
120
+ marginTop: fromOffset(-height)
121
+ })
122
+ }
123
+ };
93
124
  function view(element) {
94
125
  var window = isNode(element) ? element : document.createElement("form");
95
126
  init();
@@ -104,5 +135,7 @@ function view(element) {
104
135
  })
105
136
  if (window.resizable) resize.on(window);
106
137
  }
138
+ on('resize')(window, resize2);
139
+ onmounted(window, resize2);
107
140
  return window;
108
141
  }