efront 3.5.1 → 3.5.5

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.
@@ -86,6 +86,16 @@ var bindTarget = function (index, element) {
86
86
  };
87
87
 
88
88
  var hooka = function (matcher, move, event, targetChild, isMovingSource) {
89
+ var dragbox = this.dragbox;
90
+ if (dragbox instanceof Function) {
91
+ dragbox = dragbox.call(this);
92
+ if (dragbox && !getTargetIn(dragbox, event.target)) return;
93
+ }
94
+ else {
95
+ dragbox = this;
96
+ }
97
+ var that = this;
98
+
89
99
  var draggingSourceOpacity = isMovingSource !== false ? 0 : 1;
90
100
 
91
101
  var recover = function (element) {
@@ -130,41 +140,89 @@ var hooka = function (matcher, move, event, targetChild, isMovingSource) {
130
140
  }
131
141
  var targetBox, saved_opacity, saved_filter, moveMargin, moveChildren;
132
142
  var previousElements, followedElements, rebuildTargets, scroll;
133
- if (getTargetIn(this, targetChild)) {
134
- targetBox = targetChild.parentNode;
135
- previousElements = getPreviousElementSiblings(targetChild);
136
- followedElements = getFollowedElementSiblings(targetChild);
137
- saved_filter = targetBox.style.filter;
138
- saved_opacity = targetBox.style.opacity;
139
- rebuildTargets = function () { };
140
- [moveMargin, moveChildren, scroll] = getMoveFuncs(targetChild);
141
- moveChildren = moveChildren.bind(null, targetBox, previousElements, followedElements, moveMargin, recover);
142
- } else {
143
- previousElements = [];
144
- followedElements = [];
145
- moveChildren = () => { };
146
- rebuildTargets = function () {
147
- var temp = matcher(drag.target);
148
- if (temp === targetBox) return;
149
- if (previousElements) previousElements.map(recover);
150
- if (followedElements) followedElements.map(recover);
151
- if (targetBox) {
152
- removeClass(targetBox, "dropping");
153
- }
154
- targetBox = temp;
155
- if (!targetBox) {
156
- previousElements = [];
143
+ var that = this;
144
+ var draginit = function () {
145
+ that.setAttribute('dragchildren', '');
146
+ if (targetBox) addClass(targetBox, 'dropping');
147
+ if (getTargetIn(dragbox, targetChild)) {
148
+ targetBox = targetChild.parentNode;
149
+ previousElements = getPreviousElementSiblings(targetChild);
150
+ followedElements = getFollowedElementSiblings(targetChild);
151
+ saved_filter = targetBox.style.filter;
152
+ saved_opacity = targetBox.style.opacity;
153
+ rebuildTargets = function () { };
154
+ [moveMargin, moveChildren, scroll] = getMoveFuncs(targetChild);
155
+ moveChildren = moveChildren.bind(null, that, previousElements, followedElements, moveMargin, recover);
156
+ } else {
157
+ previousElements = [];
158
+ followedElements = [];
159
+ moveChildren = () => { };
160
+ rebuildTargets = function () {
161
+ var temp = matcher(drag.target);
162
+ if (temp === targetBox) return;
163
+ if (previousElements) previousElements.map(recover);
164
+ if (followedElements) followedElements.map(recover);
165
+ if (targetBox) {
166
+ removeClass(targetBox, "dropping");
167
+ }
168
+ targetBox = temp;
169
+ if (!targetBox) {
170
+ previousElements = [];
171
+ followedElements = [];
172
+ moveChildren = () => { };
173
+ return;
174
+ }
175
+ addClass(targetBox, "dropping");
176
+ previousElements = [].slice.call(targetBox.children, 0).reverse();
157
177
  followedElements = [];
158
- moveChildren = () => { };
159
- return;
178
+ [moveMargin, moveChildren, scroll] = getMoveFuncs(previousElements[0]);
179
+ moveChildren = moveChildren.bind(null, that, previousElements, followedElements, moveMargin, recover);
180
+ };
181
+ }
182
+ };
183
+ var dragfire = function () {
184
+ that.removeAttribute('dragchildren');
185
+ removeClass(targetBox, "dropping");
186
+ var dst, appendSibling, delta;
187
+ var src = previousElements.length;
188
+ if (previousElements.length && previousElements[0].moved) for (var cx = 1, dx = previousElements.length + 1; cx < dx; cx++) {
189
+ if (!previousElements[cx]) {
190
+ dst = 0;
191
+ delta = 0;
192
+ appendSibling = appendChild.before;
193
+ } else if (!previousElements[cx].moved) {
194
+ dst = previousElements.length - cx;
195
+ delta = -1;
196
+ appendSibling = appendChild.after;
197
+ break;
160
198
  }
161
- addClass(targetBox, "dropping");
162
- previousElements = [].slice.call(targetBox.children, 0).reverse();
163
- followedElements = [];
164
- [moveMargin, moveChildren, scroll] = getMoveFuncs(previousElements[0]);
165
- moveChildren = moveChildren.bind(null, targetBox, previousElements, followedElements, moveMargin, recover);
166
- };
167
- }
199
+ }
200
+
201
+ if (followedElements.length && followedElements[0].moved) for (var cx = 1, dx = followedElements.length + 1; cx < dx; cx++) {
202
+ if (!followedElements[cx]) {
203
+ dst = followedElements.length + previousElements.length;
204
+ delta = 0;
205
+ appendSibling = appendChild.after;
206
+ } else if (!followedElements[cx].moved) {
207
+ dst = previousElements.length + cx;
208
+ delta = 1;
209
+ appendSibling = appendChild.before;
210
+ break;
211
+ }
212
+ }
213
+ if (appendSibling) {
214
+ var children = targetBox.children;
215
+ var srcElement = children[src];
216
+ var dstElement = children[dst + delta];
217
+ src = bindTarget(src, srcElement);
218
+ dst = bindTarget(dst, dstElement);
219
+ isFunction(move) && move(src, dst, dst + delta, appendSibling, targetBox);
220
+ if (srcElement === children[src] && dstElement === children[dst + delta] && srcElement && dstElement) appendSibling(dstElement, srcElement);
221
+ } else if (isMovingSource === false) {
222
+ move(previousElements.length, previousElements.length, previousElements.length, null, targetBox);
223
+ }
224
+ };
225
+
168
226
  var offall = function () {
169
227
  offmousup();
170
228
  offtouchend();
@@ -190,8 +248,8 @@ var hooka = function (matcher, move, event, targetChild, isMovingSource) {
190
248
 
191
249
  // 修改margin无效的情况
192
250
  function dragclone() {
251
+ draginit();
193
252
  rebuildTargets();
194
- if (targetBox) addClass(targetBox, 'dropping');
195
253
  var _previousElements = previousElements.map(cloneCell);
196
254
  var _followedElements = followedElements.map(cloneCell);
197
255
  previousElements.splice(0, previousElements.length);
@@ -204,109 +262,33 @@ var hooka = function (matcher, move, event, targetChild, isMovingSource) {
204
262
  var offall = function () {
205
263
  offdragmove();
206
264
  offdragend();
207
- removeClass(targetBox, "dropping");
208
265
  };
209
266
  var offdragend = on("dragend")(targetChild, function () {
210
267
  offall();
268
+ dragfire();
211
269
  css(targetBox, { opacity: saved_opacity, filter: saved_filter });
212
270
  remove(previousElements);
213
271
  remove(followedElements);
214
- var dst, appendSibling, delta;
215
- var src = previousElements.length;
216
- if (previousElements.length && previousElements[0].moved) for (var cx = 1, dx = previousElements.length + 1; cx < dx; cx++) {
217
- if (!previousElements[cx]) {
218
- dst = 0;
219
- delta = 0;
220
- appendSibling = appendChild.before;
221
- } else if (!previousElements[cx].moved) {
222
- dst = previousElements.length - cx;
223
- delta = -1;
224
- appendSibling = appendChild.after;
225
- break;
226
- }
227
- }
228
-
229
- if (followedElements.length && followedElements[0].moved) for (var cx = 1, dx = followedElements.length + 1; cx < dx; cx++) {
230
- if (!followedElements[cx]) {
231
- dst = followedElements.length + previousElements.length;
232
- delta = 0;
233
- appendSibling = appendChild.after;
234
- } else if (!followedElements[cx].moved) {
235
- dst = previousElements.length + cx;
236
- delta = 1;
237
- appendSibling = appendChild.before;
238
- break;
239
- }
240
- }
241
272
  previousElements.map(recover);
242
273
  followedElements.map(recover);
243
- if (appendSibling) {
244
- var children = targetBox.children;
245
- var srcElement = children[src];
246
- var dstElement = children[dst + delta];
247
- src = bindTarget(src, srcElement);
248
- dst = bindTarget(dst, dstElement);
249
- isFunction(move) && move(src, dst, dst + delta, appendSibling, targetBox);
250
- if (srcElement === children[src] && dstElement === children[dst + delta] && srcElement && dstElement) appendSibling(dstElement, srcElement);
251
- } else if (isMovingSource === false) {
252
- move(previousElements.length, previousElements.length, previousElements.length, null, targetBox);
253
- }
254
274
  });
255
275
  var offdragmove = on("dragmove")(targetChild, dragmove);
256
276
  }
257
277
  // 仅修改Margin就可以实现拖拽效果
258
278
  function draglist() {
279
+ draginit();
259
280
  rebuildTargets();
260
- if (targetBox) addClass(targetBox, 'dropping');
261
281
  autoScroll();
262
282
  var offall = function () {
263
283
  cancelScroll();
264
284
  offdragmove();
265
285
  offdragend();
266
- if (targetBox) removeClass(targetBox, "dropping");
267
286
  };
268
287
  var offdragend = on("dragend")(targetChild, function () {
269
288
  offall();
270
- var dst, appendSibling, delta;
271
- var src = previousElements.length;
272
- if (previousElements.length && previousElements[0].moved) for (var cx = 1, dx = previousElements.length + 1; cx < dx; cx++) {
273
- if (!previousElements[cx]) {
274
- dst = 0;
275
- delta = 0;
276
- appendSibling = appendChild.before;
277
- } else if (!previousElements[cx].moved) {
278
- dst = previousElements.length - cx;
279
- delta = -1;
280
- appendSibling = appendChild.after;
281
- break;
282
- }
283
- }
284
-
285
- if (followedElements.length && followedElements[0].moved) for (var cx = 1, dx = followedElements.length + 1; cx < dx; cx++) {
286
- if (!followedElements[cx]) {
287
- dst = followedElements.length + previousElements.length;
288
- delta = 0;
289
- appendSibling = appendChild.after;
290
- } else if (!followedElements[cx].moved) {
291
- dst = previousElements.length + cx;
292
- delta = 1;
293
- appendSibling = appendChild.before;
294
- break;
295
- }
296
- }
289
+ dragfire();
297
290
  previousElements.map(e => moveMargin(e, false));
298
291
  followedElements.map(e => moveMargin(e, false));
299
- if (appendSibling) {
300
- var children = targetBox.children;
301
- var srcElement = children[src];
302
- var dstElement = children[dst + delta];
303
- src = bindTarget(src, srcElement);
304
- dst = bindTarget(dst, dstElement);
305
- isFunction(move) && move(src, dst, dst + delta, appendSibling, targetBox);
306
- if (srcElement === children[src] && dstElement === children[dst + delta] && srcElement && dstElement) appendSibling(dstElement, srcElement);
307
- } else if (isMovingSource === false) {
308
- move(previousElements.length, previousElements.length, previousElements.length, null, targetBox);
309
- }
310
292
  });
311
293
  var offdragmove = on("dragmove")(targetChild, dragmove);
312
294
  }
@@ -320,9 +302,7 @@ var hookEvent = function (matcher, move, event) {
320
302
  if (event.target === this) return;
321
303
  var targetChild = getTargetIn(matcher, event.target, false);
322
304
  if (!targetChild) return;
323
- var dragbox = this.dragbox;
324
- if (dragbox instanceof Function) dragbox = dragbox.call(this);
325
- hooka.call(dragbox || this, matcher, move, event, targetChild);
305
+ hooka.call(this, matcher, move, event, targetChild);
326
306
  };
327
307
  function addhook() {
328
308
  var mousedownEvent, targetElement, callback, matcher, dropid, allowdrops;
@@ -46,6 +46,8 @@ function drag(target, initialEvent, preventOverflow, isMovingSource) {
46
46
  var [target_left, target_top] = getOffset(target);
47
47
  if (abs(target_left - event.screenX - saved_delta.x) < MOVELOCK_DELTA && abs(target_top - event.screenY - saved_delta.y) < MOVELOCK_DELTA) return;
48
48
  saved_delta.ing = true;
49
+ drag.target = target;
50
+ dispatch("dragstart", target);
49
51
  if (isElement(target) && !/absolute|fixed/.test(getComputedStyle(target).position)) {
50
52
  clone = toCloneTarget(target, isMovingSource);
51
53
  appendChild(document.body, clone);
@@ -62,7 +64,6 @@ function drag(target, initialEvent, preventOverflow, isMovingSource) {
62
64
  clone.style.zIndex = zIndex();
63
65
  extraClones.map(e => e.style.zIndex = clone.style.zIndex);
64
66
  }
65
- dispatch("dragstart", target);
66
67
  }
67
68
  drag.target = clone;
68
69
  var offsetLeft = saved_delta.x + event.screenX;
@@ -91,6 +91,10 @@ var adaptTarget = function (event) {
91
91
  }
92
92
  if (target) target = getFirstSingleColCell(this, target.colend);
93
93
  if (target) {
94
+ if (position.right >= getSelection(this).right - 7) {
95
+ target = this;
96
+ return;
97
+ }
94
98
  css(this, { 'cursor': 'e-resize' });
95
99
  result = {
96
100
  target,
@@ -117,6 +121,7 @@ function table(elem) {
117
121
  move: resizeTarget,
118
122
  });
119
123
  onmousemove(tableElement, function (event) {
124
+ if (!thead) [thead] = table.getElementsByTagName("thead");
120
125
  if (!getTargetIn(thead, event.target)) return;
121
126
  var tds = getTargetIn(cellMatchManager, event.target);
122
127
  if (!isArray(tds)) tds = [];
@@ -155,6 +160,7 @@ function table(elem) {
155
160
  return thead;
156
161
  };
157
162
  care(table, function ([fields, data]) {
163
+ thead = null;
158
164
  this.innerHTML = template;
159
165
  render(this, {
160
166
  fields,
@@ -1,16 +1,17 @@
1
- & {
2
-
1
+ &[dragchildren] {
3
2
  >thead,
4
3
  >tbody,
5
4
  & {
6
5
  >tr {
7
-
6
+
8
7
  >th,
9
8
  >td {
10
- box-shadow: 0 0 20px -6px #00000033;
9
+ box-shadow: 1px 0 0 0 #00000033, -1px 0 0 0 #00000033;
11
10
  }
11
+
12
12
  }
13
13
  }
14
+
14
15
  }
15
16
 
16
17
  thead,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.5.1",
3
+ "version": "3.5.5",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {