efront 3.12.2 → 3.12.6

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.
@@ -46,7 +46,7 @@ function toResponse() {
46
46
  if (this.responseType === 'json') return JSON.stringify(this.response);
47
47
  return this.response;
48
48
  }
49
- function _cross(jsonp, digest = noop, method, url, headers) {
49
+ function cross_(jsonp, digest = noop, method, url, headers) {
50
50
  var originDomain = getDomainPath(url);
51
51
  if (!originDomain) throw new Error("路径格式错误!");
52
52
  var _cookies = getCookies(originDomain);
@@ -149,7 +149,7 @@ function _cross(jsonp, digest = noop, method, url, headers) {
149
149
  }
150
150
  location = getRequestProtocol(url) + "//" + location;
151
151
  }
152
- var crs = _cross("get", location, _headers);
152
+ var crs = cross_("get", location, _headers);
153
153
  crs.isRedirected = (xhr.isRedirected || 0) + 1;
154
154
  crs.done(onload, false);
155
155
  crs.error(onerror, false);
@@ -304,10 +304,10 @@ function reform(r, info, fire, cancel, e) {
304
304
  function addReform(r) {
305
305
  if (isFunction(r)) reforms.push(r);
306
306
  }
307
- var bind = _cross.bind;
308
- _cross.bind = function () {
309
- var _cross = bind.apply(this, arguments);
310
- extend(_cross, {
307
+ var bind = cross_.bind;
308
+ cross_.bind = function () {
309
+ var cross_ = bind.apply(this, arguments);
310
+ extend(cross_, {
311
311
  requests,
312
312
  abortAll() {
313
313
  var rs = requests.splice(0, requests.length);
@@ -320,10 +320,10 @@ _cross.bind = function () {
320
320
  addDirect,
321
321
  getCrossUrl
322
322
  });
323
- return _cross;
323
+ return cross_;
324
324
  }
325
- _cross.setHost = setHost;
326
- _cross.setLocation = function (host) {
325
+ cross_.setHost = setHost;
326
+ cross_.setLocation = function (host) {
327
327
  location_href = host;
328
328
  if (!base) base = /^https?\:/i.test(location_href) ? '/' : "http://efront.cc/";
329
329
  };
@@ -4,7 +4,6 @@ a => {
4
4
  if (!m) throw new Error("无法加载数据!");
5
5
  if (m) a = m[1];
6
6
  a = JSON.parse(a);
7
- console.log(a)
8
7
  }
9
8
  return a.map(b => {
10
9
  var data = {};
@@ -1,4 +1,4 @@
1
- return _cross.bind(function (callback, onerror) {
1
+ return cross_.bind(function (callback, onerror) {
2
2
  var response, responseObject, responseType = "", error;
3
3
  var xhr = {
4
4
  status: 0,
@@ -1,11 +1,11 @@
1
1
  // 激活 自定义的 active 事件
2
- function active(target, value, item, targetElement) {
2
+ function active(target, value, item = value, srcElem) {
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;
6
+ if (srcElem) {
7
+ if (Object.defineProperty) Object.defineProperty(activeEvent, 'currentTarget', { value: srcElem });
8
+ else activeEvent.currentTarget = srcElem;
9
9
  }
10
10
  activeEvent = dispatch(target, activeEvent);
11
11
  return activeEvent && !activeEvent.defaultPrevented;
@@ -16,7 +16,25 @@ var active = function () {
16
16
  __addClass(this, "hover active");
17
17
  };
18
18
  var checkclick = function () {
19
- if (this.hasAttribute("disabled") || this.disabled || this.hasAttribute("loading") || this.loading || this.hasAttribute("pending") || this.pending) onclick.preventClick = true;
19
+ if (this.hasAttribute("disabled") || this.disabled || this.hasAttribute("loading") || this.loading || this.hasAttribute("pending") || this.pending) {
20
+ onclick.preventClick = true;
21
+ return;
22
+ }
23
+ if (this.hasAttribute("confirm") || this.confirm) {
24
+ if (!this.confirm_sign) {
25
+ addClass(this, 'confirm');
26
+ var that = this;
27
+ that.confirm_sign = true;
28
+ setTimeout(function () {
29
+ removeClass(that, "confirm");
30
+ delete that.confirm_sign;
31
+ }, 2000);
32
+ onclick.preventClick = true;
33
+ return;
34
+ }
35
+ delete this.confirm_sign;
36
+ removeClass(this, "confirm");
37
+ }
20
38
  };
21
39
  var resetactive = function () {
22
40
  removeClass(this, "active");
@@ -259,4 +259,11 @@ a&,
259
259
  }
260
260
 
261
261
  text-shadow: none;
262
+ }
263
+
264
+ &.confirm {
265
+ &:before {
266
+ content: "确认";
267
+ }
268
+ background: #333;
262
269
  }
@@ -27,6 +27,8 @@ function chooseFile(accept, multiple, extra) {
27
27
  }
28
28
  });
29
29
  });
30
- input.click();
30
+ setTimeout(function(){
31
+ input.click();
32
+ });
31
33
  return result;
32
34
  }
@@ -5,7 +5,7 @@ var saveCookie = lazy(function () {
5
5
  var { efrontURI, cross_host = efrontURI } = this;
6
6
  var location_href = parseURL(location.href);
7
7
  location_href = `${location_href.protocol}//${location_href.host}/`;
8
- _cross.setLocation(location_href);
8
+ cross_.setLocation(location_href);
9
9
 
10
10
  var cookieItemsInSessionStorageKey = "--zimoli-coms-cross";
11
11
  var cookiesData = sessionStorage.getItem(cookieItemsInSessionStorageKey);
@@ -21,7 +21,7 @@ var digest = function () {
21
21
  dispatch('render', window);
22
22
  };
23
23
 
24
- var cross = _cross.bind(function (callback, onerror) {
24
+ var cross = cross_.bind(function (callback, onerror) {
25
25
  var xhr = new XMLHttpRequest;
26
26
  var abort = xhr.abort;
27
27
  xhr.abort = function () {
@@ -55,6 +55,6 @@ cross.setHost = function (host) {
55
55
  if (!host) return console.error("cross_host格式不正确", host);
56
56
  var host = parsed.host + (parsed.pathname || '/');
57
57
  host = (/^https/.test(location_href) ? "https://" : "http://") + host;
58
- _cross.setHost(host);
58
+ cross_.setHost(host);
59
59
  };
60
60
  if (cross_host) cross.setHost(cross_host);
@@ -19,9 +19,15 @@ var transfromSimpleValue = function (value) {
19
19
  };
20
20
  var transformValue = function (value, k) {
21
21
  if (ratioPropReg.test(k) || !value) return value;
22
- if (/^[\w\s\.]+$/.test(value)) return isFinite(value) ? transfromSimpleValue(value) : String(value).split(/\s/).map(transfromSimpleValue).join(' ');
22
+ if (/^[\w\s\.]+$/.test(value)) return isFinite(value) ? transfromSimpleValue(value) : String(value).split(/\s+/).map(transfromSimpleValue).join(' ');
23
23
  return value;
24
24
  };
25
+ var partifyValue = function (v) {
26
+ return String(v).toLowerCase().split(/['"`]|\s+/).join(" ");
27
+ };
28
+ var isSameValue = function (v1, v2) {
29
+ return partifyValue(v1) === partifyValue(v2);
30
+ };
25
31
  /**
26
32
  * 将中划线转成驼峰式
27
33
  * @param {string} key
@@ -86,7 +92,8 @@ var cssTargetNode = function (targetNode, oStyle, oValue) {
86
92
  var key = transformNodeKey(k);
87
93
  if (key in styleobject) {
88
94
  try {
89
- styleobject[key] = transformValue(oStyle[k], key);
95
+ var value = transformValue(oStyle[k], key);
96
+ if (!isSameValue(value, styleobject[value])) styleobject[key] = transformValue(oStyle[k], key);
90
97
  } catch (e) {
91
98
  console.warn(key, oStyle[k], "无效");
92
99
  }
@@ -95,7 +102,8 @@ var cssTargetNode = function (targetNode, oStyle, oValue) {
95
102
  } else {
96
103
  for (var k in oStyle) {
97
104
  var key = transformNodeKey(k);
98
- if (key in styleobject) styleobject[key] = transformValue(oStyle[k], key);
105
+ var value = transformValue(oStyle[k], key);
106
+ if (key in styleobject && !isSameValue(value, styleobject[key])) styleobject[key] = value;
99
107
  }
100
108
  }
101
109
  }
@@ -153,9 +161,9 @@ function cssTargetStyleSheet(stylesheet, innerCss) {
153
161
  var styleSheet = stylesheet.styleSheet;
154
162
  if (styleSheet) {
155
163
  //IE
156
- styleSheet.cssText = innerCss;
164
+ if (styleSheet.cssText !== innerCss) styleSheet.cssText = innerCss;
157
165
  } else {
158
- stylesheet.innerHTML = innerCss;
166
+ if (stylesheet.innerHTML !== innerCss) stylesheet.innerHTML = innerCss;
159
167
  }
160
168
  }
161
169
 
@@ -165,6 +165,7 @@ function getUrlParamsForApi(api, url) {
165
165
  var params = {};
166
166
  url = url.replace(/[\?#]*$/g, function (match) {
167
167
  match.split(/[&#\?]+/).forEach(function (s) {
168
+ if (!s) return;
168
169
  var [k, v] = s.split("=");
169
170
  params[k] = v;
170
171
  });
@@ -176,7 +177,7 @@ function getUrlParamsForApi(api, url) {
176
177
  });
177
178
  });
178
179
  params = serialize(params);
179
- return api.id + "?" + params;
180
+ return params;
180
181
  }
181
182
 
182
183
  function __seekprop(data, prop) {
@@ -204,7 +205,7 @@ function seekResponse(data, seeker, apiMap = {}) {
204
205
  }
205
206
  if (data && prop) {
206
207
  var reg1 = /[\:\>\\]/, next;
207
- var getNextValue = /[\>\\]/.test(prop);
208
+ var getNextValue = !/\:/.test(prop);
208
209
  if (reg1.test(prop)) {
209
210
  var [prop, next, pick] = prop.split(reg1);
210
211
  next = apiMap[next];
@@ -231,8 +232,8 @@ function seekResponse(data, seeker, apiMap = {}) {
231
232
  data = JSON.parse(data);
232
233
  }
233
234
  if (next) {
234
- data = getUrlParamsForApi(next, data);
235
- if (pick || getNextValue) {
235
+ data = (pick || next.id) + "?" + getUrlParamsForApi(next, data);
236
+ if (getNextValue) {
236
237
  data = getParamsFromUrl(data);
237
238
  if (pick) data = data[pick];
238
239
  }
@@ -894,7 +895,7 @@ var data = {
894
895
  return data;
895
896
  });
896
897
  promise1.catch((e) => {
897
- if (e === outdate) return;
898
+ if (e === outdate || e === aborted) return;
898
899
  this.responseCrash(e, instance);
899
900
  });
900
901
 
@@ -29,7 +29,9 @@ var encode62 = {
29
29
  timeencode(string) {
30
30
  var { time_delta } = this;
31
31
  var time_free = time_delta / 6 | 0;
32
- var time_stamp = +new Date() - time_free;
32
+ var time = +new Date;
33
+ time = time - time % (time_delta >> 2);
34
+ var time_stamp = time - time_free;
33
35
  var time_rest = time_stamp % time_delta;
34
36
  var time_rest_str = time_rest.toString(36);
35
37
  var time_delta_str = time_delta.toString(36);
@@ -39,9 +41,10 @@ var encode62 = {
39
41
  timeupdate(string) {
40
42
  var { time_delta } = this;
41
43
  var time_rest = string.slice(string.length - time_delta.toString(36).length, string.length);
42
- var time_start = parseInt((new Date() - parseInt(time_rest, 36)) / time_delta) * time_delta;
44
+ var time = +new Date;
45
+ var time_start = parseInt((time - parseInt(time_rest, 36)) / time_delta) * time_delta;
43
46
  var time_stamp = time_start + parseInt(time_rest, 36);
44
- if (time_stamp + (time_delta >> 1) > +new Date()) {
47
+ if (time_stamp + (time_delta >> 1) > time) {
45
48
  return string;
46
49
  } else {
47
50
  return this.timeencode(this.timedecode(string));
@@ -2,7 +2,7 @@
2
2
  var _slider = createElement(div);
3
3
  var getGenerator = function (container, tagName = 'item') {
4
4
  if (!container) return;
5
- if (!container.childNodes.length && container.$generator) return container.$generator;
5
+ if (container.$generator) return container.$generator;
6
6
  var template = document.createElement(tagName);
7
7
  var templates = [].concat.apply([], container.childNodes).filter(a => {
8
8
  if (a.hasAttribute('insert')) {
@@ -404,12 +404,6 @@ function ylist(container, generator, $Y) {
404
404
  var scrolled = (list.scrollTop - firstElement.offsetTop + parseFloat(getComputedStyle(list).paddingTop) + .5 | 0) / firstElement.offsetHeight;
405
405
  return index + scrolled;
406
406
  };
407
- on("remove")(list, function () {
408
- saved_itemIndex = list.index();
409
- });
410
- on("append")(list, function () {
411
- if (isFinite(saved_itemIndex)) list.go(saved_itemIndex);
412
- })
413
407
  list.topIndex = function () {
414
408
  var element = getFirstElement(1);
415
409
  return element ? element.index : 0;
@@ -419,6 +413,12 @@ function ylist(container, generator, $Y) {
419
413
  list.patchTop = patchTop;
420
414
  list.scrollIfNotCover = scrollIfNotCover;
421
415
  vbox(list, $Y);
416
+ on("remove")(list, function () {
417
+ saved_itemIndex = list.index();
418
+ });
419
+ on("append")(list, function () {
420
+ if (isFinite(saved_itemIndex)) list.go(saved_itemIndex);
421
+ })
422
422
  return list;
423
423
  }
424
424
  var allArgumentsNames = arguments[arguments.length - 1];
@@ -154,14 +154,24 @@ function main(elem, mode) {
154
154
  case "y":
155
155
  case "vertical":
156
156
  var emit = function (item, target) {
157
- active(elem, item, item.value, target);
157
+ active(elem, item.value, item, target);
158
158
  };
159
159
  if ("$src" in elem) {
160
160
  getGenerator(elem, 'menu-item');
161
- care(elem, function (src) {
162
- menuList(elem, getTreeFromData(src), emit, direction);
161
+ on("append")(elem, function () {
163
162
  elem.registerAsRoot();
164
163
  });
164
+ var src0 = [];
165
+ menuList(elem, src0, emit, direction);
166
+ care(elem, function (src) {
167
+ src0.splice(0, src0.length);
168
+ var s = getTreeFromData(src);
169
+ var i = 0;
170
+ while (i < s.length) {
171
+ src0.push.apply(src0, s.slice(i, i += 1000));
172
+ }
173
+ elem.go(0);
174
+ });
165
175
  }
166
176
  else {
167
177
  var nodes = getArrayNodes(elem);
@@ -275,7 +275,6 @@ function main(page, items, active, direction = 'y') {
275
275
  var className = `{'has-children':${itemName}.children&&${itemName}.children.length,'warn':${itemName}.type==='danger'||${itemName}.type==='warn'||${itemName}.type==='red'}`;
276
276
  var notHidden = `!${itemName}.hidden`;
277
277
  var generator = getGenerator(page, 'menu-item');
278
-
279
278
  list(page, function (index) {
280
279
  var item = items[index];
281
280
  if (!item) return;
@@ -100,7 +100,7 @@ var constructors = {
100
100
  break;
101
101
  }
102
102
  }
103
- var pad = selectList(field.options, field.multi, true);
103
+ var pad = selectList(field.options, !!field.multi, true);
104
104
  var e = document.createElement('select');
105
105
  e.innerHTML = `<option selected value="${opt ? opt.key : ''}">${opt ? opt.name : '请选择'}</option>`;
106
106
  e.value = opt ? opt.key : '';
@@ -17,8 +17,15 @@ var getstation = function (n, s) {
17
17
  return n;
18
18
  };
19
19
  var _createImage = function (url, callback) {
20
- var imgpic = document.createElement('img');
21
- imgpic.src = url;
20
+ var imgpic;
21
+ if (url instanceof Image) {
22
+ imgpic = new Image;
23
+ imgpic.src = url.src;
24
+ }
25
+ else {
26
+ imgpic = document.createElement('img');
27
+ imgpic.src = url;
28
+ }
22
29
  var onload = function () {
23
30
  imgpic.onload = null;
24
31
  callback(imgpic);
@@ -393,7 +400,6 @@ function picture(url, to = 0, key) {
393
400
  var gen = function (index, ratio) {
394
401
  if (index >= urls.length || index < 0) return null;
395
402
  if (images[index] && images[index].url !== urls[index]) {
396
- console.log(images[index].url, urls[index]);
397
403
  delete images[index];
398
404
  }
399
405
  if (!images[index]) {
@@ -152,10 +152,6 @@ var createMask = function (element) {
152
152
  return mask;
153
153
  };
154
154
  var popup_with_mask = function (element, mask = createMask(element)) {
155
- if (!mask.clean) {
156
- mask.clean = new Cleanup(element.with);
157
- }
158
- onremove(element, mask.clean);
159
155
  css(element, `z-index:${zIndex()};`);
160
156
  if (mask.parentNode) {
161
157
  global(element, false);
@@ -167,6 +163,10 @@ var popup_with_mask = function (element, mask = createMask(element)) {
167
163
  } else {
168
164
  if (element.with !== element) element.with = [element.with, mask];
169
165
  }
166
+ if (!mask.clean) {
167
+ mask.clean = new Cleanup(element.with);
168
+ }
169
+ onremove(element, mask.clean);
170
170
  if (!element.parentNode) global(element, false);
171
171
  return element;
172
172
  };
@@ -381,7 +381,7 @@ var src2 = function (search) {
381
381
  temp = "";
382
382
  }
383
383
  var changes = getChanges(temp, savedValue);
384
- if (!changes || isEmpty(origin) && isEmpty(this.src)) return;
384
+ if (!changes || isEmpty(origin) && isEmpty(this.src) && isEmpty(savedValue)) return;
385
385
  savedValue = temp;
386
386
  this.src = origin;
387
387
  cast(this, origin);
@@ -42,12 +42,12 @@ function select(target, list, removeOnSelect, direction) {
42
42
  direction = removeOnSelect;
43
43
  removeOnSelect = arguments[3];
44
44
  }
45
- if (direction === undefined) {
46
- direction = target.getAttribute("direction") || target.direction;
47
- }
48
45
  if (!target) {
49
46
  target = document.createElement("select");
50
47
  }
48
+ if (direction === undefined) {
49
+ direction = target.getAttribute("direction") || target.direction;
50
+ }
51
51
  target.tabIndex = 0;
52
52
  onblur(target, removeByBlur);
53
53
  if (/select/i.test(target.tagName)) {
@@ -116,7 +116,7 @@ function select(target, list, removeOnSelect, direction) {
116
116
  else if (target.$src) {
117
117
  var generator = getGenerator(target);
118
118
  var initList2 = function (src) {
119
- list = selectList(generator, src, target.multiple, target.editable);
119
+ list = selectList(generator, src, !!target.multiple, !!target.editable);
120
120
  if (!target.multiple) {
121
121
  onclick(list, onlistclick);
122
122
  }
@@ -158,7 +158,7 @@ function select(target, list, removeOnSelect, direction) {
158
158
  var allOptions = [].concat.apply([], target.querySelectorAll("option"));
159
159
  if (deepEqual.shallow(allOptions, savedOptions)) return;
160
160
  savedOptions = allOptions;
161
- list = selectList(allOptions, target.multiple, target.editable);
161
+ list = selectList(allOptions, !!target.multiple, !!target.editable);
162
162
  if (!target.multiple) {
163
163
  onclick(list, onlistclick);
164
164
  }
@@ -39,14 +39,17 @@ function main() {
39
39
  generator = a;
40
40
  break;
41
41
  case "boolean":
42
- if (multiple === void 0) multiple = a;
43
- else addable = a;
42
+ case "undefined":
43
+ if (multiple === void 0) multiple = !!a;
44
+ else addable = !!a;
45
+ break;
44
46
  case "object":
45
47
  if (isNode(a)) {
46
48
  page = a;
47
49
  if (!generator) generator = getGenerator(page);
48
50
  }
49
51
  else if (a.length) children = a;
52
+ break;
50
53
 
51
54
  }
52
55
  }
@@ -122,17 +122,23 @@ function slider(autoplay, circle = true) {
122
122
  };
123
123
  var park = function () {
124
124
  direction = 0;
125
- if (delta_negative_index > 0) {
126
- if (negative_index - floor(negative_index) > 0.3 / (1 + abs(_speed())))
125
+ var singleTarget = getSingleTarget();
126
+ if (singleTarget) {
127
+ negative_index = round(negative_index);
128
+ }
129
+ else if (delta_negative_index > 0) {
130
+ if (negative_index - floor(negative_index) > 0.2 / (1 + 6 * abs(_speed())))
127
131
  negative_index = ceil(negative_index);
128
132
  else
129
133
  negative_index = floor(negative_index);
130
- } else if (delta_negative_index < 0) {
131
- if (ceil(negative_index) - negative_index > 0.3 / (1 + abs(_speed())))
134
+ }
135
+ else if (delta_negative_index < 0) {
136
+ if (ceil(negative_index) - negative_index > 0.2 / (1 + 6 * abs(_speed())))
132
137
  negative_index = floor(negative_index);
133
138
  else
134
139
  negative_index = ceil(negative_index);
135
- } else {
140
+ }
141
+ else {
136
142
  negative_index = round(negative_index);
137
143
  }
138
144
  animate();
@@ -173,9 +179,10 @@ function slider(autoplay, circle = true) {
173
179
  }
174
180
  return enabled;
175
181
  };
182
+ var getSingleTarget = () => (!_imageMain || !_imageHelp) && (_imageMain || _imageHelp);
176
183
  var moveDeltaX = function (deltax, event) {
177
184
  var width = outter.clientWidth;
178
- var singleTarget = (!_imageMain || !_imageHelp) && (_imageMain || _imageHelp);
185
+ var singleTarget = getSingleTarget();
179
186
  if (singleTarget) {
180
187
  var current_Left = singleTarget.offsetLeft;
181
188
  var avail_deltaWidth = round(width >> 2);
@@ -201,7 +201,7 @@ function ybox(generator) {
201
201
  }
202
202
  this.YScrollBoxId = +scrollId + 1;
203
203
  }
204
- if (_box.isMounted) initScrollId.call(_box);
204
+ if (isMounted(_box)) initScrollId.call(_box);
205
205
  on("append")(_box, initScrollId);
206
206
  _box.cancelFrame = function () {
207
207
  cancelAnimationFrame(smooth_timer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.12.2",
3
+ "version": "3.12.6",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {