efront 3.26.8 → 3.26.15

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 (67) hide show
  1. package/LICENSE +2 -0
  2. package/apps/index.jsp +2 -2
  3. package/apps/pivot/dht/list.js +53 -0
  4. package/apps/pivot/index.html +3 -1
  5. package/apps/pivot/main.js +1 -0
  6. package/apps/pivot/main.less +3 -0
  7. package/apps/pivot/wow/root.js +138 -104
  8. package/apps/pivot/wow/root.less +1 -62
  9. package/coms/basic/Task.js +51 -0
  10. package/coms/basic/cross_.js +8 -0
  11. package/coms/basic/keys.js +3 -4
  12. package/coms/basic/loader.js +42 -17
  13. package/coms/basic/submit_.js +6 -3
  14. package/coms/explorer/Explorer.js +85 -0
  15. package/coms/explorer/context.js +205 -0
  16. package/coms/explorer/deepcp.js +48 -0
  17. package/{apps/pivot/wow → coms/explorer}/edit.html +1 -1
  18. package/{apps/pivot/wow → coms/explorer}/edit.js +17 -9
  19. package/coms/explorer/fileitem.html +8 -0
  20. package/coms/explorer/fileitem.js +34 -0
  21. package/coms/explorer/fileitem.less +65 -0
  22. package/coms/explorer/filetip.js +10 -0
  23. package/coms/explorer/filetip.less +5 -0
  24. package/coms/explorer/main.html +8 -0
  25. package/coms/explorer/main.js +215 -0
  26. package/coms/explorer/main.less +78 -0
  27. package/coms/frame/route.js +1 -1
  28. package/coms/shapes/file.html +9 -0
  29. package/coms/shapes/folder.html +7 -0
  30. package/coms/zimoli/Cleanup.js +9 -8
  31. package/coms/zimoli/arriswise.js +5 -4
  32. package/coms/zimoli/attr.js +2 -0
  33. package/coms/zimoli/bindGlobalkey.js +37 -0
  34. package/coms/zimoli/confirm.js +8 -8
  35. package/coms/zimoli/confirm.less +6 -80
  36. package/coms/zimoli/container.js +19 -6
  37. package/coms/zimoli/contextmenu.js +35 -15
  38. package/coms/zimoli/drag.js +7 -3
  39. package/coms/zimoli/field.html +1 -1
  40. package/coms/zimoli/field.js +8 -2
  41. package/coms/zimoli/field.less +0 -1
  42. package/coms/zimoli/getChanges.js +1 -0
  43. package/coms/zimoli/list.js +44 -33
  44. package/coms/zimoli/menu.js +1 -24
  45. package/coms/zimoli/menuItem.html +4 -1
  46. package/coms/zimoli/menuList.js +54 -104
  47. package/coms/zimoli/menuList.less +1 -0
  48. package/coms/zimoli/moveupon.js +2 -2
  49. package/coms/zimoli/overpos.js +7 -0
  50. package/coms/zimoli/popup.js +22 -27
  51. package/coms/zimoli/prompt.js +43 -5
  52. package/coms/zimoli/prompt.less +23 -0
  53. package/coms/zimoli/render.js +153 -109
  54. package/coms/zimoli/resize.js +17 -7
  55. package/coms/zimoli/rootElements.js +15 -1
  56. package/coms/zimoli/view.js +33 -0
  57. package/coms/zimoli/view.less +8 -8
  58. package/coms/zimoli/yousure.js +53 -0
  59. package/coms/zimoli/yousure.less +4 -0
  60. package/coms/zimoli/zimoli.js +10 -6
  61. package/package.json +1 -1
  62. package/public/efront.js +1 -1
  63. package/apps/pivot/wow/root.html +0 -10
  64. package/coms/zimoli/explorer.html +0 -5
  65. package/coms/zimoli/explorer.js +0 -8
  66. package/coms/zimoli/explorer.less +0 -18
  67. 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);
@@ -273,11 +284,12 @@ var createIf = function (search, id = 0) {
273
284
  var shouldMount = -1;
274
285
  for (var cx = 0, dx = elements.length; cx < dx; cx += 2) {
275
286
  var getter = elements[cx + 1];
276
- if (!getter || getter()) {
287
+ if (!getter || getter(this)) {
277
288
  shouldMount = cx;
278
289
  break;
279
290
  }
280
291
  }
292
+ // console.log(shouldMount,savedValue,this,this.$scope)
281
293
  if (savedValue === shouldMount) return;
282
294
  savedValue = shouldMount;
283
295
  for (var cx = 0, dx = elements.length; cx < dx; cx += 2) {
@@ -368,7 +380,10 @@ var renderStructure = function (element) {
368
380
  if ($struct.if) var { name: ifkey, key, value: ifexp } = $struct.if;
369
381
  if ($struct.repeat) var { value: repeat } = $struct.repeat;
370
382
  if (!ifkey) return createRepeat.call(element, repeat);
371
- if (!ifexp || !repeat) return structures[key].call(element, ifexp);
383
+ if (!ifexp || !repeat) {
384
+ delete $struct.if;
385
+ return structures[key].call(element, ifexp);
386
+ }
372
387
  var { before, after } = parseIfWithRepeat(ifexp, repeat);
373
388
  if (after.length) {
374
389
  $struct.if = { key, name: ifkey, value: after.join("&&") };
@@ -400,7 +415,7 @@ var structures = {
400
415
  initIf(if_top.splice(cx + 1, if_top.length - cx - 1));
401
416
  var top = if_top[cx];
402
417
  if (search && search) {
403
- var getter = createGetter(search).bind(this);
418
+ var getter = createGetter(this, search);
404
419
  }
405
420
  var comment = createComment.call(this, undefined, search ? 'elseif' : 'else', search);
406
421
  top.push(comment, getter);
@@ -413,10 +428,10 @@ structures["else-if"] = structures.elseif = structures.else;
413
428
  structures["for-each"] = structures.foreach = structures.for = structures.each = structures.repeat;
414
429
  var createBinder = function (binder) {
415
430
  return function (search) {
416
- var getter = createGetter(`(${search})`).bind(this);
431
+ var getter = createGetter(this, `(${search})`);
417
432
  var oldValue;
418
433
  this.renders.push(function () {
419
- var value = getter();
434
+ var value = getter(this);
420
435
  if (deepEqual.shallow(value, oldValue)) return;
421
436
  oldValue = value;
422
437
  if (isNode(value) || isArray(value)) {
@@ -434,10 +449,10 @@ var createBinder = function (binder) {
434
449
  }
435
450
 
436
451
  var src2 = function (search) {
437
- var getter = createGetter(search).bind(this);
452
+ var getter = createGetter(this, search);
438
453
  var savedValue;
439
454
  this.renders.push(function () {
440
- var origin = getter();
455
+ var origin = getter(this);
441
456
  var temp = origin;
442
457
  if (origin instanceof Array) {
443
458
  temp = extend([], origin);
@@ -469,36 +484,36 @@ var directives = {
469
484
  var parsedSrc = this.$src;
470
485
  return src2.call(this, parsedSrc ? parsedSrc.srcName : src);
471
486
  },
472
- model(search) {
473
- var getter = createGetter(search).bind(this);
487
+ model(search, target) {
488
+ var getter = createGetter(this, search);
474
489
  var oldValue;
475
- var getstr = this.getValue instanceof Function ? "this.getValue()" : "";
476
- var setter = this.setValue instanceof Function ? function () {
477
- var value = getter();
490
+ var getstr = target.getValue instanceof Function ? "this.getValue()" : "";
491
+ var setter = target.setValue instanceof Function ? function () {
492
+ var value = getter(this);
478
493
  if (value === undefined) value = "";
479
494
  if (deepEqual(oldValue, value)) return;
480
495
  oldValue = value;
481
496
  this.setValue(value);
482
497
  } : null;
483
498
  var setter2 = function (key) {
484
- var value = getter();
499
+ var value = getter(this);
485
500
  if (value === undefined) value = "";
486
501
  if (deepEqual(oldValue, value)) return;
487
502
  oldValue = value;
488
503
  this[key] = value;
489
504
  };
490
- if (/^input$/i.test(this.tagName) && /^checkbox$/i.test(this.type) || /^checkbox$/i.test(this.tagName)) {
491
- this.renders.push(setter || setter2.bind(this, 'checked'));
505
+ if (/^input$/i.test(target.tagName) && /^checkbox$/i.test(target.type) || /^checkbox$/i.test(target.tagName)) {
506
+ this.renders.push(setter || setter2.bind(target, 'checked'));
492
507
  var change = getstr || "this.checked";
493
- } else if (("value" in this || this.getValue instanceof Function) && this.setValue instanceof Function) {
508
+ } else if (("value" in target || target.getValue instanceof Function) && target.setValue instanceof Function) {
494
509
  this.renders.push(setter);
495
510
  var change = getstr || "this.value";
496
- } else if (/^(select|input|textarea)$/i.test(this.tagName) || "value" in this) {
497
- this.renders.push(setter || setter2.bind(this, 'value'));
511
+ } else if (/^(select|input|textarea)$/i.test(target.tagName) || "value" in target) {
512
+ this.renders.push(setter || setter2.bind(target, 'value'));
498
513
  var change = getstr || "this.value";
499
514
  } else {
500
515
  this.renders.push(setter || function () {
501
- var value = getter();
516
+ var value = getter(this);
502
517
  if (value === undefined) value = "";
503
518
  if (deepEqual(oldValue, value)) return;
504
519
  oldValue = value;
@@ -507,24 +522,25 @@ var directives = {
507
522
  var change = getstr || "'value' in this?this.value:this.innerHTML";
508
523
  }
509
524
  setter2 = null;
525
+ var changeme = $$eval.bind(this, search + "=" + change, null);
510
526
  var onchange = function () {
511
- $eval.call(this, search + "=" + change, this.$scope);
512
- var value = getter();
527
+ changeme(this);
528
+ var value = getter(this);
513
529
  if (value === oldValue) {
514
530
  return;
515
531
  }
516
532
  oldValue = value;
517
533
  userChanged = true;
518
534
  };
519
- eventsBinders.forEach(on => on(this, onchange, true));
535
+ eventsBinders.forEach(on => on(target, onchange, true));
520
536
  },
521
537
 
522
538
  "class"(search) {
523
- var getter = createGetter(`(${search})`).bind(this);
539
+ var getter = createGetter(this, `(${search})`);
524
540
  var generatedClassNames = {};
525
541
  var oldValue;
526
542
  this.renders.push(function () {
527
- var className = getter();
543
+ var className = getter(this);
528
544
  if (deepEqual(oldValue, className)) return;
529
545
  oldValue = className;
530
546
  var originalClassNames = [];
@@ -560,10 +576,10 @@ directives.text = directives.bind;
560
576
  var binders = {
561
577
  _(attr, search) {
562
578
  attr = attr.replace(/\-(\w)/g, (_, w) => w.toUpperCase());
563
- var getter = createGetter(search).bind(this);
579
+ var getter = createGetter(this, search);
564
580
  var oldValue;
565
581
  this.renders.push(function () {
566
- var value = getter();
582
+ var value = getter(this);
567
583
  if (deepEqual(value, oldValue)) return;
568
584
  oldValue = value;
569
585
  if (this[attr] !== value) {
@@ -572,10 +588,10 @@ var binders = {
572
588
  });
573
589
  },
574
590
  ""(attr, search) {
575
- var getter = createGetter(search).bind(this);
591
+ var getter = createGetter(this, search);
576
592
  var oldValue;
577
593
  this.renders.push(function () {
578
- var value = getter();
594
+ var value = getter(this);
579
595
  if (deepEqual(value, oldValue)) return;
580
596
  oldValue = value;
581
597
  if (value === true || value === '') {
@@ -591,10 +607,12 @@ var binders = {
591
607
  }
592
608
  };
593
609
  var reject = function (e) { digest(); throw e };
594
- var createEmiter = function (on) {
595
- return function (key, search) {
596
- var parsedSrc = this.$src;
597
- var getter = createGetter(search, false);
610
+ var createEmiter = function (on, target) {
611
+ return function (target, key, search) {
612
+ /**
613
+ * @type {Repeater}
614
+ */
615
+ var getter = createGetter(this, search, false);
598
616
  var onkey;
599
617
  if (key === 'mounted' || key === 'mount') {
600
618
  onkey = on === once ? oncemount : onmounted;
@@ -605,18 +623,24 @@ var createEmiter = function (on) {
605
623
  else {
606
624
  onkey = on(key);
607
625
  }
608
- onkey(this, function (e) {
626
+ onkey(target, function (e) {
609
627
  digest();
610
- if (parsedSrc) {
611
- var target = e.currentTarget || e.target;
612
- var scopes = target && target.$parentScopes;
613
- if (scopes) {
614
- var scope = null;
615
- for (var cx = scopes.length - 1; cx >= 0; cx--) {
616
- var s = scopes[cx];
617
- if (s === this.$scope) {
618
- scope = scopes[cx + 1];
619
- break;
628
+ var parsedSrc = this.$src;
629
+ if (parsedSrc instanceof Repeater) {
630
+ var target = e.currentTarget === this ? e.target : e.currentTarget || e.target;
631
+ if (target === this) {
632
+ scope = parsedSrc.createScope();
633
+ }
634
+ else {
635
+ var scopes = target && target.$parentScopes;
636
+ if (scopes) {
637
+ var scope = null;
638
+ for (var cx = scopes.length - 1; cx >= 0; cx--) {
639
+ var s = scopes[cx];
640
+ if (s === this.$scope) {
641
+ scope = scopes[cx + 1];
642
+ break;
643
+ }
620
644
  }
621
645
  }
622
646
  }
@@ -627,12 +651,12 @@ var createEmiter = function (on) {
627
651
  var temp = this.$scope;
628
652
  this.$parentScopes.push(temp);
629
653
  this.$scope = scope;
630
- res = getter.call(this, e);
654
+ res = getter(this, e);
631
655
  this.$parentScopes.pop();
632
656
  this.$scope = temp;
633
657
  }
634
658
  else {
635
- res = getter.call(this, e);
659
+ res = getter(this, e);
636
660
  }
637
661
  if (res && isFunction(res.then)) res.then(digest, reject);
638
662
  return res;
@@ -660,6 +684,31 @@ function getFromScopes(key, scope, parentScopes) {
660
684
  }
661
685
  }
662
686
 
687
+ function renderRest(element, struct, replacer = element) {
688
+ var renders = element.renders;
689
+ element.renders = [];
690
+ var { binds, attrs, props } = struct;
691
+ for (var k in binds) {
692
+ if (k === 'src') continue;
693
+ if (directives.hasOwnProperty(k)) {
694
+ directives[k].call(element, binds[k], replacer);
695
+ }
696
+ else {
697
+ binders._.call(element, k, binds[k]);
698
+ }
699
+ }
700
+ for (var k in struct.attrs) {
701
+ binders[""].call(element, k, attrs[k]);
702
+ }
703
+ for (var k in struct.props) {
704
+ try {
705
+ if (replacer[k] !== props[k]) replacer[k] = props[k];
706
+ } catch (e) { }
707
+ }
708
+ if (binds.src) directives.src.call(element, binds.src);
709
+ if (renders.length) element.renders.push.apply(element.renders, renders);
710
+ }
711
+
663
712
  function renderElement(element, scope = element.$scope, parentScopes = element.$parentScopes, once) {
664
713
  if (isArrayLike(element)) {
665
714
  return Array.prototype.slice.call(element).map(function (element) {
@@ -691,13 +740,11 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
691
740
  if (!element || element.renderid < 0 || element.nodeType !== 1) {
692
741
  return element;
693
742
  }
694
- var elementid = element.getAttribute("renderid") || element.getAttribute("elementid") || element.getAttribute("id");
695
- if (elementid) {
696
- if (scope[elementid] && scope[elementid] !== element) throw new Error("同一个id不能使用两次:" + elementid);
697
- scope[elementid] = element;
743
+ for (var id of element.$struct.ids) {
744
+ if (scope[id] && scope[id] !== element) throw new Error("同一个id不能使用两次:" + id);
745
+ scope[id] = element;
698
746
  }
699
747
  var isFirstRender = !element.renderid;
700
-
701
748
  if (isFirstRender) {
702
749
  element.renderid = 1;
703
750
  var parentNode = element.parentNode;
@@ -705,7 +752,7 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
705
752
  if (parentNode.renderid > 1 || isMounted(parentNode)) element.renderid = 2;
706
753
  }
707
754
  element.renders = element.renders ? [].concat(element.renders) : [];
708
- var { ons, copys, attrs, props, binds, ids, once } = element.$struct;
755
+ var { copys, binds, once } = element.$struct;
709
756
  if (once) element.renderid = 9;
710
757
  if (binds.src) {
711
758
  element.$src = parseRepeat(binds.src);
@@ -724,6 +771,11 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
724
771
  if (isFunction(constructor)) {
725
772
  var replacer = constructor.call(scope, element, scope, parentScopes);
726
773
  if (isNode(replacer) && element !== replacer) {
774
+ if (!replacer.$scope) {
775
+ replacer.$scope = scope;
776
+ }
777
+ if (replacer.children && replacer.children.length) renderElement(replacer.children, replacer.$scope, replacer.$parentScopes || parentScopes, once);
778
+ if (!replacer.$parentScopes) replacer.$parentScopes = parentScopes;
727
779
  if (nextSibling) appendChild.before(nextSibling, replacer);
728
780
  else if (parentNode) appendChild(parentNode, replacer);
729
781
  if (element.parentNode === parentNode) remove(element);
@@ -744,42 +796,29 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
744
796
  replacer.setAttribute(name, value);
745
797
  }
746
798
  });
747
- replacer.renderid = element.renderid;
748
- var renders = element.renders;
749
- if (replacer.renders) renders = renders.concat(replacer.renders);
750
- replacer.renders = renders;
751
- if (binds.src) replacer.$src = element.$src;
752
- replacer.$eval = element.$eval;
753
- element = replacer;
754
- element.$scope = scope;
755
- element.$parentScopes = parentScopes;
799
+ if (!replacer.renderid) replacer.renderid = element.renderid;
756
800
  }
757
801
  }
758
802
  }
759
- if (element.children && element.children.length) renderElement(element.children, scope, parentScopes, once);
803
+ if (!replacer || element === replacer) {
804
+ if (element.children && element.children.length) renderElement(element.children, scope, parentScopes, once);
805
+ }
760
806
  if (!isFirstRender) return element;
761
- var renders = element.renders;
762
- element.renders = [];
763
- for (var k in binds) {
764
- if (k === 'src') continue;
765
- if (directives.hasOwnProperty(k)) {
766
- directives[k].call(element, binds[k])
807
+ renderRest(element, element.$struct, replacer);
808
+ if (replacer) {
809
+ if (!replacer.renders) replacer.renders = [];
810
+ if (isElement(replacer)) createStructure(replacer);
811
+ replacer.renders = [].concat(element.renders, replacer.renders);
812
+ for (var id of element.$struct.ids) {
813
+ scope[id] = replacer;
767
814
  }
768
- else {
769
- binders._.call(element, k, binds[k]);
815
+ if (replacer.$struct && replacer.$struct !== element.$struct) {
816
+ renderRest(replacer, replacer.$struct);
817
+ element.$struct.ons.forEach(([on, key, value]) => on.call(element, replacer, key, value));
770
818
  }
819
+ element = replacer;
771
820
  }
772
- for (var k in attrs) {
773
- binders[""].call(element, k, attrs[k]);
774
- }
775
- for (var k in props) {
776
- try {
777
- if (element[k] !== props[k]) element[k] = props[k];
778
- } catch (e) { }
779
- }
780
- if (binds.src) directives.src.call(element, binds.src);
781
- ons.forEach(([on, key, value]) => on.call(element, key, value));
782
- if (renders.length) element.renders.push.apply(element.renders, renders);
821
+ if (element.$struct) element.$struct.ons.forEach(([on, key, value]) => on.call(element, element, key, value));
783
822
  if (element.renders.length) {
784
823
  if (element.renderid !== 9) {
785
824
  onmounted(element, addRenderElement);
@@ -791,21 +830,18 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
791
830
  rebuild(element);
792
831
  }
793
832
  }
794
- if (elementid) scope[elementid] = element;
795
- for (var id of ids) {
796
- scope[id] = element;
797
- }
798
833
  return element;
799
834
  }
800
835
  var createEval = function (deep) {
801
836
  var context = [];
802
837
  while (deep-- > 0) {
803
- context[deep] = `with(this.$parentScopes[${deep}])`;
838
+ context[deep] = `with($parentScopes[${deep}])`;
804
839
  }
805
- return new Function("code", "event", `${context.join('')}with(this.$scope)return eval(code)`);
840
+ return new Function("$parentScopes", "$scope", "code", "event", `${context.join('')}with($scope)return eval(code)`);
806
841
  };
807
842
  var evalcontexts = [createEval(0)];
808
- function $eval(search, scope, event) {
843
+
844
+ function $$eval(search, scope, target = this, event) {
809
845
  var needpop = scope && scope !== this.$scope;
810
846
  if (needpop) {
811
847
  this.$parentScopes.push(this.$scope);
@@ -814,11 +850,15 @@ function $eval(search, scope, event) {
814
850
  var length = this.$parentScopes ? this.$parentScopes.length : 0;
815
851
  if (!evalcontexts[length]) evalcontexts[length] = createEval(length);
816
852
  var eval2 = evalcontexts[length];
817
- var res = eval2.call(this, search, event);
853
+ var res = eval2.call(target, this.$parentScopes, this.$scope, search, event);
818
854
  if (needpop) this.$scope = this.$parentScopes.pop();
819
855
  return res;
820
856
  }
821
857
 
858
+ function $eval(search, scope, event) {
859
+ return $$eval.call(this, search, scope, this, event);
860
+ }
861
+
822
862
  class Struct {
823
863
  constructor(ons, types, copys, binds, attrs, props, ids, once) {
824
864
  this.ons = ons;
@@ -850,6 +890,10 @@ function createStructure(element) {
850
890
  var ids = [];
851
891
  for (var attr of attrs) {
852
892
  var { name, value } = attr;
893
+ if (name === 'elementid' || name === 'renderid' || name === 'id') {
894
+ ids.push(value);
895
+ continue;
896
+ }
853
897
  if (/^#/.test(name)) {
854
898
  ids.push(name.slice(1));
855
899
  element.removeAttribute(name);
@@ -860,7 +904,7 @@ function createStructure(element) {
860
904
  continue;
861
905
  }
862
906
  var key = name.replace(/^(ng|v|.*?)\-/i, "").toLowerCase();
863
- if (structures.hasOwnProperty(key) && isFunction(structures[key])) {
907
+ if (structures.hasOwnProperty(key)) {
864
908
  if (element.renderid <= -2) {
865
909
  if (/^if$|^else/i.test(key)) {
866
910
  if (types.if) {
@@ -945,7 +989,7 @@ var digest = lazy(refresh, -{});
945
989
  render.digest = render.apply = render.refresh = digest;
946
990
  render.parseRepeat = parseRepeat;
947
991
  "fullscreenchange,resize,load,hashchange".split(",").forEach(e => on(e)(window, digest));
948
- var eventsBinders = "change,click,paste,resize,keydown,keypress,keyup,input,drop".split(",").map(k => on(k));
992
+ var eventsBinders = "change,click,paste,cut,resize,keydown,keypress,keyup,input,drop".split(",").map(k => on(k));
949
993
  var userChanged = false;
950
994
  var changeListener = function () {
951
995
  if (userChanged) {
@@ -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,21 +134,27 @@ 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
 
138
145
  var offmousemove;
139
146
  var resizeh = lazy(function () {
140
147
  // 用于刷新自定义的scrollbar/lattice/gallery组件
148
+ /**
149
+ * @type {HTMLElement}
150
+ */
141
151
  var elem = this;
142
152
  var resized = false;
143
- if (elem.scrollWidth > elem.clientWidth) {
153
+ if (elem.scrollWidth > elem.offsetWidth + elem.clientLeft + 1) {
144
154
  css(elem, { width: elem.offsetWidth });
145
155
  resized = true;
146
156
  }
147
- if (elem.scrollHeight > elem.clientHeight) {
157
+ if (elem.scrollHeight > elem.offsetHeight + elem.clientTop + 1) {
148
158
  css(elem, { height: elem.offsetHeight });
149
159
  resized = true;
150
160
  }
@@ -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
  }