efront 2.44.11 → 2.45.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.
@@ -315,7 +315,7 @@ var detour = function (o, ie) {
315
315
  class Program extends Array {
316
316
  COMMENT = COMMENT
317
317
  SPACE = SPACE
318
- STAMP = STRAP
318
+ STRAP = STRAP
319
319
  STAMP = STAMP
320
320
  VALUE = VALUE
321
321
  QUOTED = QUOTED
@@ -1,9 +1,13 @@
1
1
  var styles = {
2
- log: "#2a53cd",
3
- info: "#228B22",
4
- warn: "#dd6a16",
5
- error: "#dc352e"
2
+ blue: "#2a53cd",
3
+ green: "#228B22",
4
+ orange: "#dd6a16",
5
+ red: "#dc352e"
6
6
  };
7
+ styles.success = styles.pass = styles.green;
8
+ styles.info = styles.blue;
9
+ styles.error = styles.danger = styles.red;
10
+ styles.warn = styles.orange;
7
11
  var alerts = [];
8
12
  var clean = Cleanup(alerts);
9
13
  var build = function () {
@@ -4,7 +4,6 @@ function main(elem) {
4
4
  }
5
5
  if (!/^img$/i.test(elem.tagName)) {
6
6
  care(elem, function (src) {
7
- console.log(elem);
8
7
  css(elem, { backgroundImage: `url('${src}')` });
9
8
  })
10
9
  }
@@ -1 +1 @@
1
- <s>✓</s>
1
+ ▢<s>✓</s>
@@ -1,32 +1,27 @@
1
1
  & {
2
- display: inline-block;
3
2
  height: 1em;
4
3
  width: 1em;
5
- border-radius: 2px;
6
- border: .1em solid;
7
4
  position: relative;
8
- vertical-align: middle;
9
5
  margin-right: 4px;
6
+ font-family: sans-serif;
7
+ display: inline-block;
8
+ line-height: 1;
9
+ text-align: center;
10
10
 
11
11
  >s {
12
12
  display: none;
13
- border-radius: 50%;
14
- width: 1em;
15
- height: 1em;
16
- line-height: 1;
17
13
  text-decoration: none;
18
- text-align: center;
19
14
  position: absolute;
20
- margin: -.5em;
21
15
  font-weight: bold;
22
- top: 50%;
23
- left: 50%;
16
+ left: 0;
17
+ right: 0;
18
+ top: -.15em;
24
19
  }
25
20
  }
26
21
 
27
22
 
28
23
  &.checked {
29
24
  >s {
30
- display: block;
25
+ display: inline;
31
26
  }
32
27
  }
@@ -323,7 +323,7 @@ function addDirect(a) {
323
323
  if (typeof a === 'string' || a instanceof RegExp) cors_hosts.push(a);
324
324
  }
325
325
  function notCross(domain) {
326
- if (location_host === domain.slice(0, location_host.length)) return true;
326
+ if (location_host === domain.slice(0, location_host.length) || !/^https?\:\/\/|^s?\/\//.test(domain)) return true;
327
327
  for (var cx = 0, dx = cors_hosts.length; cx < dx; cx++) {
328
328
  var host = cors_hosts[cx];
329
329
  if (host instanceof RegExp) {
@@ -166,6 +166,7 @@ function cssTargetStyleSheet(stylesheet, innerCss) {
166
166
  * @param {|string} oValue
167
167
  */
168
168
  var css = function (target, oStyle, oValue) {
169
+ if (!oStyle) return;
169
170
  if (isElement(target)) {
170
171
  if (/^style$/i.test(target.tagName)) {
171
172
  cssTargetStyleSheet(target, oStyle, oValue);
@@ -269,9 +269,9 @@ function parseConfig(api) {
269
269
  });
270
270
  return '';
271
271
  });
272
- url.replace(/[\?\#][\s\S]*$/, '').replace(/\:\w+/g, function (p) {
272
+ url.replace(/[\?\#][\s\S]*$/, '').replace(/([\:\\]\:|\:\w+)/g, function (p) {
273
273
  p = p.slice(1);
274
- if (!required[p]) {
274
+ if (!required[p] && p !== ':') {
275
275
  required.push(p);
276
276
  required[p] = p;
277
277
  }
@@ -495,8 +495,9 @@ var privates = {
495
495
  var coinmethod = method.slice(0, spliterIndex).toLowerCase();
496
496
  var realmethod = coinmethod.replace(/\W+$/g, '');
497
497
  var rest = [];
498
- var uri = url.replace(/#[\s\S]*$/, "").replace(/\:[a-z\_][\w]*/gi, function (d) {
498
+ var uri = url.replace(/#[\s\S]*$/, "").replace(/[\\\:]\:|\:[a-z\_][\w]*/gi, function (d) {
499
499
  d = d.slice(1);
500
+ if (d === ":") return d;
500
501
  rest.push(d);
501
502
  return seekResponse(params, d) || '';
502
503
  });
@@ -829,7 +830,6 @@ var data = {
829
830
  this.responseLoading(instance);
830
831
  var params = privates.pack(sid, params1);
831
832
  if (!privates.validApi(api, params)) throw aborted;
832
-
833
833
  var { method, uri, params, selector } = privates.prepare(api.method, api.url, params);
834
834
  var promise = new Promise(function (ok, oh) {
835
835
  var headers = api.headers;
@@ -850,7 +850,6 @@ var data = {
850
850
  }
851
851
  });
852
852
  }).then(function (response) {
853
-
854
853
  return transpile(seekResponse(parseData(response), selector), api.transpile, api.root);
855
854
  });
856
855
  return promise;
@@ -914,6 +913,10 @@ var data = {
914
913
  localStorage.setItem(sourceDataId, JSAM.stringify(dataSourceMap));
915
914
  }
916
915
  },
916
+ getSource(sourceid) {
917
+ if (sourceid) return dataSourceMap[sourceid];
918
+ return dataSourceMap;
919
+ },
917
920
  clearSource() {
918
921
  localStorage.removeItem(sourceDataId);
919
922
  sessionStorage.removeItem(sourceDataId);
@@ -5,6 +5,19 @@ var encode62 = {
5
5
  src,
6
6
  map,
7
7
  time_delta: parseInt("zzzzz", 36),
8
+ geta(string) {
9
+ string = String(string)
10
+ string = string.length + string + "2017-08-19";
11
+ var buff = src.split('');
12
+ for (var cx = 0, dx = buff.length + src.length, sl = string.length, cl = buff.length; cx < dx; cx++) {
13
+ var s1 = string.charCodeAt(cx % sl) % cl;
14
+ var s2 = cx % cl;
15
+ var btemp = buff[s1];
16
+ buff[s1] = buff[s2];
17
+ buff[s2] = btemp;
18
+ }
19
+ return buff.join('');
20
+ },
8
21
  timedecode(string) {
9
22
  var { time_delta } = this;
10
23
  var time_rest = string.slice(string.length - time_delta.toString(36).length, string.length);
@@ -1,8 +1,10 @@
1
1
  <div class="head">
2
2
  <span ng-bind=field.name></span>
3
+ <span class="required" ng-if="field.required">*</span>
3
4
  </div>
4
5
  <div class="body">
5
6
  <model _data=data _field=field></model>
7
+ <span class="error" ng-bind="error"></span>
6
8
  </div>
7
9
  <div class="foot" ng-if="field.msg">
8
10
  <span ng-bind=field.msg></span>
@@ -1,19 +1,43 @@
1
1
  function main(elem) {
2
- var result = elem;
3
- if (isElement(elem) && elem.hasAttribute("ng-src")) {
4
- elem = option(elem);
5
- care(elem, function (p) {
6
- var [f, data] = p;
7
- elem.innerHTML = field;
8
- render(elem, {
9
- model,
10
- data,
11
- field: f
12
- });
13
- }, false);
14
- } else {
15
- result = option.apply(null, arguments);
16
- }
17
- result.removeAttribute("tabindex");
18
- return result;
2
+ elem = option.apply(null, arguments);
3
+ var scope = {};
4
+ care(elem, function (p) {
5
+ if (elem.childNodes.length) return;
6
+ var [f, data] = p;
7
+ elem.innerHTML = field;
8
+ render(elem, scope = {
9
+ model,
10
+ data,
11
+ error: null,
12
+ field: f
13
+ });
14
+ elem.oldValue = data[f.key];
15
+ elem.setAttribute("field", f.key);
16
+ }, false);
17
+ elem.setAttribute("field", '');
18
+ elem.renders = [function () {
19
+ if (!this.src) return;
20
+ var [f, data] = this.src;
21
+ if (!f || !data) return;
22
+ var v = data[f.key];
23
+ if (!this.checked) if (v === this.oldValue || isEmpty(this.oldValue) && isEmpty(v)) return;
24
+ this.checked = false;
25
+ this.setAttribute("dirty", '');
26
+ var error = valid(f, data);
27
+ if (error) {
28
+ this.setAttribute("error", error);
29
+ switch (error) {
30
+ case "empty":
31
+ scope.error = `${f.name}是必填字段!`;
32
+ break;
33
+ }
34
+ }
35
+ else {
36
+ this.removeAttribute('error');
37
+ scope.error = null;
38
+ }
39
+ this.oldValue = data[f.key];
40
+ }]
41
+ elem.removeAttribute("tabindex");
42
+ return elem;
19
43
  }
@@ -32,4 +32,23 @@
32
32
 
33
33
  .input {
34
34
  width: 100%;
35
+ }
36
+
37
+ .required {
38
+ color: #c24;
39
+ display: inline-block;
40
+ }
41
+
42
+ &.error,
43
+ &[error] {
44
+ background: #f322;
45
+
46
+ model>* {
47
+ background: #f322;
48
+ border-color: #f32;
49
+ outline: 1px solid #f32;
50
+ }
51
+ .error{
52
+ color:#c32;
53
+ }
35
54
  }
@@ -2,5 +2,13 @@ function form(elem) {
2
2
  if (!elem) {
3
3
  elem = document.createElement("form");
4
4
  }
5
+ if (/form/i.test(elem.tagName)) {
6
+ on("submit")(elem, function (event) {
7
+ event.preventDefault();
8
+ var fields = elem.querySelectorAll(".field");
9
+ for (var f of fields) f.checked = true;
10
+ render.refresh();
11
+ });
12
+ }
5
13
  return elem;
6
14
  }
@@ -101,6 +101,14 @@ function main(elem, mode) {
101
101
  // }
102
102
  // elem.setAttribute('browser', os);
103
103
  var mode = elem.getAttribute('mode') || elem.getAttribute('type');
104
+ if (!mode) {
105
+ if (/^[xyhvtci]/i.test(elem.tagName)) {
106
+ mode = elem.tagName.slice(0, 1);
107
+ }
108
+ else if (/[xyhvtci]$/i.test(elem.tagName)) {
109
+ mode = elem.tagName.slice(0, 1);
110
+ }
111
+ }
104
112
  mode = mode ? mode.toLowerCase() : "horizonal";
105
113
  var src = elem.getAttribute("src") || elem.getAttribute("ng-src") || elem.getAttribute("v-src");
106
114
  if (src) {
@@ -133,12 +141,14 @@ function main(elem, mode) {
133
141
  });
134
142
  elem.renders.push(function () {
135
143
  var src = this.src;
144
+ var hasIcon = false;
136
145
  for (var cx = 0, dx = src; cx < dx; cx++) {
137
146
  if (src[cx].icon) {
147
+ hasIcon = true;
138
148
  break;
139
149
  }
140
150
  }
141
- elem.useIcon = true;
151
+ elem.useIcon = hasIcon;
142
152
  });
143
153
  } else {
144
154
  var nodes = getTreeNodes(elem);
@@ -160,7 +160,7 @@ body:active & {
160
160
  background: #1e282c;
161
161
 
162
162
  & s:after {
163
- top: -10px;
163
+ top: -9.2px;
164
164
  }
165
165
  }
166
166
 
@@ -2,7 +2,10 @@ function main(elem, scope, hasIcon) {
2
2
  var item = elem || document.createElement('menu-item');
3
3
  item.innerHTML = menuItem;
4
4
  if (isObject(scope) && scope !== elem.$scope) {
5
- render(item, { menu: scope, useIcon: hasIcon })
5
+ render(item, { menu: scope, useIcon: hasIcon, hasIcon })
6
+ }
7
+ else {
8
+ extendIfNeeded(elem.$scope, { useIcon: false, hasIcon: false })
6
9
  }
7
10
  return item;
8
11
  }
@@ -38,6 +38,7 @@ var constructors = {
38
38
  input,
39
39
  raw: input,
40
40
  row: textarea,
41
+ password,
41
42
  text: textarea,
42
43
  date() {
43
44
  var elem = document.createElement("input");
@@ -1,6 +1,4 @@
1
1
  <a ng-repeat="o in options" ng-click="select(o)" ng-class="{activate:o===options.active}">
2
- <r>
3
- <s></s>
4
- </r>
2
+ <r>◯<s>●</s></r>
5
3
  <span ng-bind=o.name||o></span>
6
4
  </a>
@@ -1,43 +1,31 @@
1
- & {
2
- vertical-align: top;
3
- }
4
-
5
1
  >a {
6
2
  line-height: inherit;
7
3
  margin-right: 10px;
8
- vertical-align: top;
9
4
 
10
5
  >r {
6
+ font-family: sans-serif;
11
7
  display: inline-block;
12
- height: 1em;
13
- width: 1em;
14
- border-radius: 50%;
15
- border: .1em solid;
16
8
  position: relative;
17
- vertical-align: middle;
18
9
  margin-right: 4px;
19
-
10
+ line-height: 1;
11
+ text-align: center;
12
+
20
13
  >s {
21
14
  display: none;
22
- border-radius: 50%;
23
- border: .2em solid;
24
- width: .4em;
25
- height: .4em;
26
15
  position: absolute;
27
- margin: -.2em;
28
- top: 50%;
29
- left: 50%;
16
+ text-decoration: none;
17
+ left: 0;
18
+ right: 0;
19
+ top: 0;
20
+ bottom: 0;
30
21
  }
31
22
  }
32
23
 
33
- >span {
34
- vertical-align: middle;
35
- }
36
24
 
37
25
  &.activate {
38
26
  >r {
39
27
  >s {
40
- display: block;
28
+ display: inline;
41
29
  }
42
30
  }
43
31
  }
@@ -71,7 +71,7 @@ var createGetter = function (search, isprop = true) {
71
71
  });
72
72
  }
73
73
  if (isprop) {
74
- return new Function('event', `try{${withContext}with(this.$scope){${ret}${searchContext}}}catch(e){/*console.warn(String(e))*/}`);
74
+ return new Function('event', `${withContext}with(this.$scope){${ret}${searchContext}}`);
75
75
  }
76
76
  return new Function("event", `${withContext}with(this.$scope){${/([\=\(\+\-])/.test(searchContext) ? ret + searchContext : `${ret}${searchContext}.call(this.$scope,event)`}}`);
77
77
  };
@@ -346,13 +346,42 @@ var structures = {
346
346
  };
347
347
  structures["else-if"] = structures.elseif = structures.else;
348
348
  structures["for-each"] = structures.foreach = structures.for = structures.each = structures.repeat;
349
- var changed = function () {
350
- if (!this.dirty) this.dirty = true, this.setAttribute('dirty', '');
351
- };
349
+ var createBinder = function (binder) {
350
+ return function (search) {
351
+ var getter = createGetter(search).bind(this);
352
+ var oldValue;
353
+ this.renders.push(function () {
354
+ var value = getter();
355
+ if (deepEqual.shallow(value, oldValue)) return;
356
+ oldValue = value;
357
+ if (isNode(value) || isArray(value)) {
358
+ if (value !== this.firstChild) {
359
+ remove(this.childNodes);
360
+ appendChild(this, value);
361
+ }
362
+ } else {
363
+ if (isEmpty(value)) value = '';
364
+ if (binder(this) !== value) binder(this, value);
365
+ }
366
+ });
367
+
368
+ }
369
+ }
352
370
  var directives = {
371
+ bind: createBinder(text),
372
+ html: createBinder(html),
373
+ hide: createBinder(function (elem, value) {
374
+ if (arguments.length === 1) return elem.style.display === 'none';
375
+ elem.style.display = value ? 'none' : '';
376
+ }),
377
+ show: createBinder(function (elem, value) {
378
+ if (arguments.length === 1) return elem.style.display !== 'none';
379
+ elem.style.display = value ? '' : 'none';
380
+ }),
381
+ style: createBinder(css),
353
382
  src(search) {
354
383
  var getter = createGetter(search).bind(this);
355
- var savedValue, savedOrigin, pending;
384
+ var savedValue, pending;
356
385
  var refresh = function () {
357
386
  that.src = savedValue;
358
387
  removeClass(that, "pending");
@@ -372,10 +401,8 @@ var directives = {
372
401
  }
373
402
  var changes = getChanges(temp, savedValue);
374
403
  if (!changes) return;
375
- savedOrigin = origin;
376
404
  savedValue = temp;
377
405
  if (/^img$/i.test(this.tagName)) {
378
- // this.setAttribute("src", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=");
379
406
  if (!isString(origin)) {
380
407
  return;
381
408
  }
@@ -394,23 +421,6 @@ var directives = {
394
421
  }
395
422
  });
396
423
  },
397
- bind(search) {
398
- var getter = createGetter(search).bind(this);
399
- var oldValue;
400
- this.renders.push(function () {
401
- var value = getter();
402
- if (deepEqual(value, oldValue)) return;
403
- oldValue = value;
404
- if (isNode(value) || isArray(value)) {
405
- if (value !== this.firstChild) {
406
- remove(this.childNodes);
407
- appendChild(this, value);
408
- }
409
- } else {
410
- if (text(this) !== value) text(this, value);
411
- }
412
- });
413
- },
414
424
  model(search) {
415
425
  var getter = createGetter(search).bind(this);
416
426
  var oldValue;
@@ -462,35 +472,6 @@ var directives = {
462
472
  }
463
473
  var onchange = change;
464
474
  eventsHandlers.map(on => on(this, onchange));
465
- eventsHandlers.map(on => on(this, changed));
466
- },
467
- hide(search) {
468
- var getter = createGetter(search).bind(this);
469
- var oldValue;
470
- this.renders.push(function () {
471
- var value = !!getter();
472
- if (deepEqual(oldValue, value)) return;
473
- oldValue = value;
474
- if (value) {
475
- this.style.display = "none";
476
- } else {
477
- this.style.display = "";
478
- }
479
- });
480
- },
481
- show(search) {
482
- var getter = createGetter(search).bind(this);
483
- var oldValue;
484
- this.renders.push(function () {
485
- var value = !!getter();
486
- if (deepEqual(oldValue, value)) return;
487
- oldValue = value;
488
- if (value) {
489
- this.style.display = "";
490
- } else {
491
- this.style.display = "none";
492
- }
493
- });
494
475
  },
495
476
 
496
477
  "class"(search) {
@@ -528,16 +509,6 @@ var directives = {
528
509
  }
529
510
  });
530
511
  },
531
- style(search) {
532
- var getter = createGetter(search).bind(this);
533
- var oldValue;
534
- this.renders.push(function () {
535
- var stylesheet = getter();
536
- if (deepEqual(oldValue, stylesheet)) return;
537
- oldValue = stylesheet;
538
- css(this, stylesheet);
539
- });
540
- }
541
512
  };
542
513
  // property binder
543
514
  var binders = {
@@ -38,4 +38,5 @@ extend(renderDefaults, {
38
38
  swap,
39
39
  password,
40
40
  table,
41
+ form,
41
42
  });
@@ -0,0 +1,41 @@
1
+ function submit(fields, data) {
2
+ var params = {};
3
+ var inputs = [];
4
+ var select = [];
5
+ var checks = [];
6
+ var id = 0;
7
+ for (var f of fields) {
8
+ var error = valid(f, data);
9
+ if (error === "empty") {
10
+ if (f.options || /date|time|range|switch|swap|radio/i.test(f.type)) {
11
+ if (!select.id) select.id = ++id;
12
+ select.push(f);
13
+ }
14
+ else {
15
+ if (!inputs.id) inputs.id = ++id;
16
+ inputs.push(f);
17
+ }
18
+ }
19
+ else if (error) {
20
+ checks.push(f);
21
+ }
22
+ else {
23
+ params[f.key] = data[f.key];
24
+ }
25
+ }
26
+ if (checks.length + select.length + inputs.length) {
27
+ var errors = [];
28
+ if (inputs.length) errors.push("请输入" + inputs.map(f => f.name).join("、"));
29
+ if (select.length) errors.push("请选择" + select.map(f => f.name).join("、"));
30
+ if (select.id < inputs.id) {
31
+ errors = errors.reverse();
32
+ }
33
+ if (checks.length) {
34
+ errors.push(checks.map(f => f.name).join("、") + "格式错误");
35
+ }
36
+ errors = errors.join(",") + "!";
37
+ alert(errors, 'error');
38
+ throw new Error(errors);
39
+ }
40
+ return params;
41
+ }
@@ -94,11 +94,6 @@ var init = function () {
94
94
  function view(element) {
95
95
  var window = isNode(element) ? element : document.createElement("form");
96
96
  init();
97
- if (/form/i.test(window.tagName)) {
98
- on("submit")(window, function (event) {
99
- event.preventDefault();
100
- });
101
- }
102
97
  extend(window, prototype);
103
98
  if (window !== element) {
104
99
  extend(window, element);
@@ -13,13 +13,15 @@ body>& {
13
13
  -ms-user-select: none;
14
14
  -moz-user-select: none;
15
15
  -webkit-user-select: none;
16
+ border: 1px solid #0006;
16
17
  }
17
18
 
18
19
  &[dragable] {
19
20
  position: absolute;
20
21
  }
21
22
 
22
- &>.body {
23
+ &>.body,
24
+ >[body] {
23
25
  padding: 6px 0;
24
26
  background: #f2f4f6;
25
27
  display: block;
@@ -42,7 +44,8 @@ body>& {
42
44
  }
43
45
 
44
46
 
45
- &>.head {
47
+ &>.head,
48
+ >[head] {
46
49
  z-index: 2;
47
50
  background: #fffc;
48
51
  position: relative;
@@ -83,12 +86,14 @@ body>& {
83
86
  }
84
87
  }
85
88
 
86
- &>.foot {
89
+ &>.foot,
90
+ >[foot] {
87
91
  white-space: nowrap;
88
92
  overflow: auto;
89
93
  }
90
94
 
91
- &>.foot {
95
+ &>.foot,
96
+ >[foot] {
92
97
  z-index: 1;
93
98
  text-align: right;
94
99
  line-height: 1;
@@ -101,13 +106,14 @@ body>& {
101
106
  bottom: 0;
102
107
  margin-top: -42px;
103
108
 
104
- .button {
105
- padding: 0 20px;
106
- min-width: 60px;
107
- vertical-align: middle;
109
+ }
108
110
 
109
- &+.button {
110
- margin-left: 10px;
111
- }
111
+ .button {
112
+ padding: 0 20px;
113
+ min-width: 60px;
114
+ vertical-align: middle;
115
+
116
+ &+.button {
117
+ margin-left: 10px;
112
118
  }
113
119
  }