scrivito_editors 1.1.1 → 1.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/scrivito_editors/binary_editor.js +132 -3
  3. data/app/assets/javascripts/scrivito_editors/enum_editor.js +42 -49
  4. data/app/assets/javascripts/scrivito_editors/linklist_editor.js +3 -2
  5. data/app/assets/javascripts/scrivito_editors/multienum_editor.js +39 -34
  6. data/app/assets/javascripts/scrivito_editors/permalink_editor.js +3 -0
  7. data/app/assets/javascripts/scrivito_editors/referencelist_editor.js +4 -2
  8. data/app/assets/javascripts/scrivito_editors/slider_editor.js +15 -5
  9. data/app/assets/javascripts/scrivito_editors/stringlist_editor.js +3 -0
  10. data/app/assets/javascripts/scrivito_editors.js +14 -2
  11. data/app/assets/stylesheets/scrivito_editors/{editors/image_drop_editor.css → image_drop_editor.css} +0 -0
  12. data/app/assets/stylesheets/{scrivito-editors-imglykit-override.css → scrivito_editors/imglykit_override.css} +0 -0
  13. data/app/assets/stylesheets/scrivito_editors/{editors/link_editor.css → link_editor.css} +0 -0
  14. data/app/assets/stylesheets/scrivito_editors/{editors/linklist_editor.css → linklist_editor.css} +2 -2
  15. data/app/assets/stylesheets/scrivito_editors/{editors/medium_editor.css → medium_editor.css} +0 -0
  16. data/app/assets/stylesheets/scrivito_editors/{editors/redactor_editor.css → redactor_editor.css} +0 -0
  17. data/app/assets/stylesheets/scrivito_editors/{editors/referencelist_editor.css → referencelist_editor.css} +2 -2
  18. data/app/assets/stylesheets/scrivito_editors/ui_container.css +105 -0
  19. data/app/assets/stylesheets/scrivito_editors.css +1 -1
  20. data/lib/scrivito_editors/engine.rb +1 -1
  21. data/{app → vendor}/assets/images/imgly_sdk/ui/night/blur/blur.png +0 -0
  22. data/{app → vendor}/assets/images/imgly_sdk/ui/night/buttons/back.png +0 -0
  23. data/{app → vendor}/assets/images/imgly_sdk/ui/night/buttons/done-highlighted.png +0 -0
  24. data/{app → vendor}/assets/images/imgly_sdk/ui/night/buttons/done.png +0 -0
  25. data/{app → vendor}/assets/images/imgly_sdk/ui/night/cancel.png +0 -0
  26. data/{app → vendor}/assets/images/imgly_sdk/ui/night/close.png +0 -0
  27. data/{app → vendor}/assets/images/imgly_sdk/ui/night/crop/16-9.png +0 -0
  28. data/{app → vendor}/assets/images/imgly_sdk/ui/night/crop/4-3.png +0 -0
  29. data/{app → vendor}/assets/images/imgly_sdk/ui/night/crop/custom.png +0 -0
  30. data/{app → vendor}/assets/images/imgly_sdk/ui/night/crop/square.png +0 -0
  31. data/{app → vendor}/assets/images/imgly_sdk/ui/night/crosshair.png +0 -0
  32. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/a15.png +0 -0
  33. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/breeze.png +0 -0
  34. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/bw.png +0 -0
  35. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/bwhard.png +0 -0
  36. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/celsius.png +0 -0
  37. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/chest.png +0 -0
  38. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/default.png +0 -0
  39. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/fixie.png +0 -0
  40. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/food.png +0 -0
  41. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/fridge.png +0 -0
  42. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/front.png +0 -0
  43. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/glam.png +0 -0
  44. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/gobblin.png +0 -0
  45. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/identity.png +0 -0
  46. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/k1.png +0 -0
  47. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/k2.png +0 -0
  48. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/k6.png +0 -0
  49. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/kdynamic.png +0 -0
  50. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/lenin.png +0 -0
  51. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/lomo.png +0 -0
  52. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/mellow.png +0 -0
  53. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/morning.png +0 -0
  54. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/orchid.png +0 -0
  55. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/pola.png +0 -0
  56. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/pola669.png +0 -0
  57. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/quozi.png +0 -0
  58. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/semired.png +0 -0
  59. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/sunny.png +0 -0
  60. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/texas.png +0 -0
  61. data/{app → vendor}/assets/images/imgly_sdk/ui/night/filters/x400.png +0 -0
  62. data/{app → vendor}/assets/images/imgly_sdk/ui/night/flip/horizontal.png +0 -0
  63. data/{app → vendor}/assets/images/imgly_sdk/ui/night/flip/vertical.png +0 -0
  64. data/{app → vendor}/assets/images/imgly_sdk/ui/night/loading.gif +0 -0
  65. data/{app → vendor}/assets/images/imgly_sdk/ui/night/operations/brightness.png +0 -0
  66. data/{app → vendor}/assets/images/imgly_sdk/ui/night/operations/contrast.png +0 -0
  67. data/{app → vendor}/assets/images/imgly_sdk/ui/night/operations/crop.png +0 -0
  68. data/{app → vendor}/assets/images/imgly_sdk/ui/night/operations/filters.png +0 -0
  69. data/{app → vendor}/assets/images/imgly_sdk/ui/night/operations/flip.png +0 -0
  70. data/{app → vendor}/assets/images/imgly_sdk/ui/night/operations/focus.png +0 -0
  71. data/{app → vendor}/assets/images/imgly_sdk/ui/night/operations/frames.png +0 -0
  72. data/{app → vendor}/assets/images/imgly_sdk/ui/night/operations/orientation.png +0 -0
  73. data/{app → vendor}/assets/images/imgly_sdk/ui/night/operations/radial-blur.png +0 -0
  74. data/{app → vendor}/assets/images/imgly_sdk/ui/night/operations/rotation.png +0 -0
  75. data/{app → vendor}/assets/images/imgly_sdk/ui/night/operations/saturation.png +0 -0
  76. data/{app → vendor}/assets/images/imgly_sdk/ui/night/operations/stickers.png +0 -0
  77. data/{app → vendor}/assets/images/imgly_sdk/ui/night/operations/text.png +0 -0
  78. data/{app → vendor}/assets/images/imgly_sdk/ui/night/operations/tilt-shift.png +0 -0
  79. data/{app → vendor}/assets/images/imgly_sdk/ui/night/rotation/left.png +0 -0
  80. data/{app → vendor}/assets/images/imgly_sdk/ui/night/rotation/right.png +0 -0
  81. data/{app → vendor}/assets/images/imgly_sdk/ui/night/slider/minus.png +0 -0
  82. data/{app → vendor}/assets/images/imgly_sdk/ui/night/slider/plus.png +0 -0
  83. data/{app → vendor}/assets/images/imgly_sdk/ui/night/top/aspect.png +0 -0
  84. data/{app → vendor}/assets/images/imgly_sdk/ui/night/top/new.png +0 -0
  85. data/{app → vendor}/assets/images/imgly_sdk/ui/night/top/original.png +0 -0
  86. data/{app → vendor}/assets/images/imgly_sdk/ui/night/top/undo.png +0 -0
  87. data/{app → vendor}/assets/images/imgly_sdk/ui/night/top/zoom-in.png +0 -0
  88. data/{app → vendor}/assets/images/imgly_sdk/ui/night/top/zoom-out.png +0 -0
  89. data/{app → vendor}/assets/images/imgly_sdk/ui/night/transparency.png +0 -0
  90. data/{app → vendor}/assets/images/imgly_sdk/ui/night/upload.png +0 -0
  91. data/{app → vendor}/assets/javascripts/canvas-to-blob.js +0 -0
  92. data/{app → vendor}/assets/javascripts/imglykit.js +0 -0
  93. data/{app → vendor}/assets/javascripts/jquery-ui-timepicker-addon.min.js +0 -0
  94. data/vendor/assets/javascripts/jquery.tag-editor.js +68 -38
  95. data/vendor/assets/javascripts/scrivito_editors_sortable.js +1278 -0
  96. data/{app → vendor}/assets/stylesheets/imglykit-night-ui.css +0 -0
  97. data/{app → vendor}/assets/stylesheets/jquery-ui-timepicker-addon.min.css +0 -0
  98. data/vendor/assets/stylesheets/jquery.tag-editor.css +9 -13
  99. data/{app → vendor}/assets/stylesheets/redactor.css +0 -0
  100. metadata +91 -92
  101. data/app/assets/javascripts/scrivito_editors_addons.js +0 -5
  102. data/app/assets/javascripts/scrivito_editors_core.js +0 -8
  103. data/app/assets/stylesheets/scrivito_editors/editors/button_container.css +0 -33
@@ -0,0 +1,1278 @@
1
+ /**!
2
+ * Sortable
3
+ * @author RubaXa <trash@rubaxa.org>
4
+ * @license MIT
5
+ *
6
+ * CHANGES BY SCRIVITO:
7
+ *
8
+ * Taken from https://github.com/RubaXa/Sortable/blob/master/Sortable.js
9
+ *
10
+ * We changed the library so it registers not in the window but under the scrivito.editors
11
+ * namespace and thereby does not pollute the global namespace. See line 29.
12
+ *
13
+ */
14
+
15
+ (function (factory) {
16
+ "use strict";
17
+
18
+ if (typeof define === "function" && define.amd) {
19
+ define(factory);
20
+ }
21
+ else if (typeof module != "undefined" && typeof module.exports != "undefined") {
22
+ module.exports = factory();
23
+ }
24
+ else if (typeof Package !== "undefined") {
25
+ Sortable = factory(); // export for Meteor.js
26
+ }
27
+ else {
28
+ /* jshint sub:true */
29
+ scrivito.editors["Sortable"] = factory();
30
+ }
31
+ })(function () {
32
+ "use strict";
33
+
34
+ if (typeof window == "undefined" || typeof window.document == "undefined") {
35
+ return function() {
36
+ throw new Error( "Sortable.js requires a window with a document" );
37
+ }
38
+ }
39
+
40
+ var dragEl,
41
+ parentEl,
42
+ ghostEl,
43
+ cloneEl,
44
+ rootEl,
45
+ nextEl,
46
+
47
+ scrollEl,
48
+ scrollParentEl,
49
+
50
+ lastEl,
51
+ lastCSS,
52
+ lastParentCSS,
53
+
54
+ oldIndex,
55
+ newIndex,
56
+
57
+ activeGroup,
58
+ autoScroll = {},
59
+
60
+ tapEvt,
61
+ touchEvt,
62
+
63
+ moved,
64
+
65
+ /** @const */
66
+ RSPACE = /\s+/g,
67
+
68
+ expando = 'Sortable' + (new Date).getTime(),
69
+
70
+ win = window,
71
+ document = win.document,
72
+ parseInt = win.parseInt,
73
+
74
+ supportDraggable = !!('draggable' in document.createElement('div')),
75
+ supportCssPointerEvents = (function (el) {
76
+ el = document.createElement('x');
77
+ el.style.cssText = 'pointer-events:auto';
78
+ return el.style.pointerEvents === 'auto';
79
+ })(),
80
+
81
+ _silent = false,
82
+
83
+ abs = Math.abs,
84
+ slice = [].slice,
85
+
86
+ touchDragOverListeners = [],
87
+
88
+ _autoScroll = _throttle(function (/**Event*/evt, /**Object*/options, /**HTMLElement*/rootEl) {
89
+ // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521
90
+ if (rootEl && options.scroll) {
91
+ var el,
92
+ rect,
93
+ sens = options.scrollSensitivity,
94
+ speed = options.scrollSpeed,
95
+
96
+ x = evt.clientX,
97
+ y = evt.clientY,
98
+
99
+ winWidth = window.innerWidth,
100
+ winHeight = window.innerHeight,
101
+
102
+ vx,
103
+ vy
104
+ ;
105
+
106
+ // Delect scrollEl
107
+ if (scrollParentEl !== rootEl) {
108
+ scrollEl = options.scroll;
109
+ scrollParentEl = rootEl;
110
+
111
+ if (scrollEl === true) {
112
+ scrollEl = rootEl;
113
+
114
+ do {
115
+ if ((scrollEl.offsetWidth < scrollEl.scrollWidth) ||
116
+ (scrollEl.offsetHeight < scrollEl.scrollHeight)
117
+ ) {
118
+ break;
119
+ }
120
+ /* jshint boss:true */
121
+ } while (scrollEl = scrollEl.parentNode);
122
+ }
123
+ }
124
+
125
+ if (scrollEl) {
126
+ el = scrollEl;
127
+ rect = scrollEl.getBoundingClientRect();
128
+ vx = (abs(rect.right - x) <= sens) - (abs(rect.left - x) <= sens);
129
+ vy = (abs(rect.bottom - y) <= sens) - (abs(rect.top - y) <= sens);
130
+ }
131
+
132
+
133
+ if (!(vx || vy)) {
134
+ vx = (winWidth - x <= sens) - (x <= sens);
135
+ vy = (winHeight - y <= sens) - (y <= sens);
136
+
137
+ /* jshint expr:true */
138
+ (vx || vy) && (el = win);
139
+ }
140
+
141
+
142
+ if (autoScroll.vx !== vx || autoScroll.vy !== vy || autoScroll.el !== el) {
143
+ autoScroll.el = el;
144
+ autoScroll.vx = vx;
145
+ autoScroll.vy = vy;
146
+
147
+ clearInterval(autoScroll.pid);
148
+
149
+ if (el) {
150
+ autoScroll.pid = setInterval(function () {
151
+ if (el === win) {
152
+ win.scrollTo(win.pageXOffset + vx * speed, win.pageYOffset + vy * speed);
153
+ } else {
154
+ vy && (el.scrollTop += vy * speed);
155
+ vx && (el.scrollLeft += vx * speed);
156
+ }
157
+ }, 24);
158
+ }
159
+ }
160
+ }
161
+ }, 30),
162
+
163
+ _prepareGroup = function (options) {
164
+ var group = options.group;
165
+
166
+ if (!group || typeof group != 'object') {
167
+ group = options.group = {name: group};
168
+ }
169
+
170
+ ['pull', 'put'].forEach(function (key) {
171
+ if (!(key in group)) {
172
+ group[key] = true;
173
+ }
174
+ });
175
+
176
+ options.groups = ' ' + group.name + (group.put.join ? ' ' + group.put.join(' ') : '') + ' ';
177
+ }
178
+ ;
179
+
180
+
181
+
182
+ /**
183
+ * @class Sortable
184
+ * @param {HTMLElement} el
185
+ * @param {Object} [options]
186
+ */
187
+ function Sortable(el, options) {
188
+ if (!(el && el.nodeType && el.nodeType === 1)) {
189
+ throw 'Sortable: `el` must be HTMLElement, and not ' + {}.toString.call(el);
190
+ }
191
+
192
+ this.el = el; // root element
193
+ this.options = options = _extend({}, options);
194
+
195
+
196
+ // Export instance
197
+ el[expando] = this;
198
+
199
+
200
+ // Default options
201
+ var defaults = {
202
+ group: Math.random(),
203
+ sort: true,
204
+ disabled: false,
205
+ store: null,
206
+ handle: null,
207
+ scroll: true,
208
+ scrollSensitivity: 30,
209
+ scrollSpeed: 10,
210
+ draggable: /[uo]l/i.test(el.nodeName) ? 'li' : '>*',
211
+ ghostClass: 'sortable-ghost',
212
+ chosenClass: 'sortable-chosen',
213
+ ignore: 'a, img',
214
+ filter: null,
215
+ animation: 0,
216
+ setData: function (dataTransfer, dragEl) {
217
+ dataTransfer.setData('Text', dragEl.textContent);
218
+ },
219
+ dropBubble: false,
220
+ dragoverBubble: false,
221
+ dataIdAttr: 'data-id',
222
+ delay: 0,
223
+ forceFallback: false,
224
+ fallbackClass: 'sortable-fallback',
225
+ fallbackOnBody: false
226
+ };
227
+
228
+
229
+ // Set default options
230
+ for (var name in defaults) {
231
+ !(name in options) && (options[name] = defaults[name]);
232
+ }
233
+
234
+ _prepareGroup(options);
235
+
236
+ // Bind all private methods
237
+ for (var fn in this) {
238
+ if (fn.charAt(0) === '_') {
239
+ this[fn] = this[fn].bind(this);
240
+ }
241
+ }
242
+
243
+ // Setup drag mode
244
+ this.nativeDraggable = options.forceFallback ? false : supportDraggable;
245
+
246
+ // Bind events
247
+ _on(el, 'mousedown', this._onTapStart);
248
+ _on(el, 'touchstart', this._onTapStart);
249
+
250
+ if (this.nativeDraggable) {
251
+ _on(el, 'dragover', this);
252
+ _on(el, 'dragenter', this);
253
+ }
254
+
255
+ touchDragOverListeners.push(this._onDragOver);
256
+
257
+ // Restore sorting
258
+ options.store && this.sort(options.store.get(this));
259
+ }
260
+
261
+
262
+ Sortable.prototype = /** @lends Sortable.prototype */ {
263
+ constructor: Sortable,
264
+
265
+ _onTapStart: function (/** Event|TouchEvent */evt) {
266
+ var _this = this,
267
+ el = this.el,
268
+ options = this.options,
269
+ type = evt.type,
270
+ touch = evt.touches && evt.touches[0],
271
+ target = (touch || evt).target,
272
+ originalTarget = target,
273
+ filter = options.filter;
274
+
275
+
276
+ if (type === 'mousedown' && evt.button !== 0 || options.disabled) {
277
+ return; // only left button or enabled
278
+ }
279
+
280
+ target = _closest(target, options.draggable, el);
281
+
282
+ if (!target) {
283
+ return;
284
+ }
285
+
286
+ // get the index of the dragged element within its parent
287
+ oldIndex = _index(target, options.draggable);
288
+
289
+ // Check filter
290
+ if (typeof filter === 'function') {
291
+ if (filter.call(this, evt, target, this)) {
292
+ _dispatchEvent(_this, originalTarget, 'filter', target, el, oldIndex);
293
+ evt.preventDefault();
294
+ return; // cancel dnd
295
+ }
296
+ }
297
+ else if (filter) {
298
+ filter = filter.split(',').some(function (criteria) {
299
+ criteria = _closest(originalTarget, criteria.trim(), el);
300
+
301
+ if (criteria) {
302
+ _dispatchEvent(_this, criteria, 'filter', target, el, oldIndex);
303
+ return true;
304
+ }
305
+ });
306
+
307
+ if (filter) {
308
+ evt.preventDefault();
309
+ return; // cancel dnd
310
+ }
311
+ }
312
+
313
+
314
+ if (options.handle && !_closest(originalTarget, options.handle, el)) {
315
+ return;
316
+ }
317
+
318
+
319
+ // Prepare `dragstart`
320
+ this._prepareDragStart(evt, touch, target);
321
+ },
322
+
323
+ _prepareDragStart: function (/** Event */evt, /** Touch */touch, /** HTMLElement */target) {
324
+ var _this = this,
325
+ el = _this.el,
326
+ options = _this.options,
327
+ ownerDocument = el.ownerDocument,
328
+ dragStartFn;
329
+
330
+ if (target && !dragEl && (target.parentNode === el)) {
331
+ tapEvt = evt;
332
+
333
+ rootEl = el;
334
+ dragEl = target;
335
+ parentEl = dragEl.parentNode;
336
+ nextEl = dragEl.nextSibling;
337
+ activeGroup = options.group;
338
+
339
+ dragStartFn = function () {
340
+ // Delayed drag has been triggered
341
+ // we can re-enable the events: touchmove/mousemove
342
+ _this._disableDelayedDrag();
343
+
344
+ // Make the element draggable
345
+ dragEl.draggable = true;
346
+
347
+ // Chosen item
348
+ _toggleClass(dragEl, _this.options.chosenClass, true);
349
+
350
+ // Bind the events: dragstart/dragend
351
+ _this._triggerDragStart(touch);
352
+ };
353
+
354
+ // Disable "draggable"
355
+ options.ignore.split(',').forEach(function (criteria) {
356
+ _find(dragEl, criteria.trim(), _disableDraggable);
357
+ });
358
+
359
+ _on(ownerDocument, 'mouseup', _this._onDrop);
360
+ _on(ownerDocument, 'touchend', _this._onDrop);
361
+ _on(ownerDocument, 'touchcancel', _this._onDrop);
362
+
363
+ if (options.delay) {
364
+ // If the user moves the pointer or let go the click or touch
365
+ // before the delay has been reached:
366
+ // disable the delayed drag
367
+ _on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
368
+ _on(ownerDocument, 'touchend', _this._disableDelayedDrag);
369
+ _on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
370
+ _on(ownerDocument, 'mousemove', _this._disableDelayedDrag);
371
+ _on(ownerDocument, 'touchmove', _this._disableDelayedDrag);
372
+
373
+ _this._dragStartTimer = setTimeout(dragStartFn, options.delay);
374
+ } else {
375
+ dragStartFn();
376
+ }
377
+ }
378
+ },
379
+
380
+ _disableDelayedDrag: function () {
381
+ var ownerDocument = this.el.ownerDocument;
382
+
383
+ clearTimeout(this._dragStartTimer);
384
+ _off(ownerDocument, 'mouseup', this._disableDelayedDrag);
385
+ _off(ownerDocument, 'touchend', this._disableDelayedDrag);
386
+ _off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
387
+ _off(ownerDocument, 'mousemove', this._disableDelayedDrag);
388
+ _off(ownerDocument, 'touchmove', this._disableDelayedDrag);
389
+ },
390
+
391
+ _triggerDragStart: function (/** Touch */touch) {
392
+ if (touch) {
393
+ // Touch device support
394
+ tapEvt = {
395
+ target: dragEl,
396
+ clientX: touch.clientX,
397
+ clientY: touch.clientY
398
+ };
399
+
400
+ this._onDragStart(tapEvt, 'touch');
401
+ }
402
+ else if (!this.nativeDraggable) {
403
+ this._onDragStart(tapEvt, true);
404
+ }
405
+ else {
406
+ _on(dragEl, 'dragend', this);
407
+ _on(rootEl, 'dragstart', this._onDragStart);
408
+ }
409
+
410
+ try {
411
+ if (document.selection) {
412
+ document.selection.empty();
413
+ } else {
414
+ window.getSelection().removeAllRanges();
415
+ }
416
+ } catch (err) {
417
+ }
418
+ },
419
+
420
+ _dragStarted: function () {
421
+ if (rootEl && dragEl) {
422
+ // Apply effect
423
+ _toggleClass(dragEl, this.options.ghostClass, true);
424
+
425
+ Sortable.active = this;
426
+
427
+ // Drag start event
428
+ _dispatchEvent(this, rootEl, 'start', dragEl, rootEl, oldIndex);
429
+ }
430
+ },
431
+
432
+ _emulateDragOver: function () {
433
+ if (touchEvt) {
434
+ if (this._lastX === touchEvt.clientX && this._lastY === touchEvt.clientY) {
435
+ return;
436
+ }
437
+
438
+ this._lastX = touchEvt.clientX;
439
+ this._lastY = touchEvt.clientY;
440
+
441
+ if (!supportCssPointerEvents) {
442
+ _css(ghostEl, 'display', 'none');
443
+ }
444
+
445
+ var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY),
446
+ parent = target,
447
+ groupName = ' ' + this.options.group.name + '',
448
+ i = touchDragOverListeners.length;
449
+
450
+ if (parent) {
451
+ do {
452
+ if (parent[expando] && parent[expando].options.groups.indexOf(groupName) > -1) {
453
+ while (i--) {
454
+ touchDragOverListeners[i]({
455
+ clientX: touchEvt.clientX,
456
+ clientY: touchEvt.clientY,
457
+ target: target,
458
+ rootEl: parent
459
+ });
460
+ }
461
+
462
+ break;
463
+ }
464
+
465
+ target = parent; // store last element
466
+ }
467
+ /* jshint boss:true */
468
+ while (parent = parent.parentNode);
469
+ }
470
+
471
+ if (!supportCssPointerEvents) {
472
+ _css(ghostEl, 'display', '');
473
+ }
474
+ }
475
+ },
476
+
477
+
478
+ _onTouchMove: function (/**TouchEvent*/evt) {
479
+ if (tapEvt) {
480
+ // only set the status to dragging, when we are actually dragging
481
+ if (!Sortable.active) {
482
+ this._dragStarted();
483
+ }
484
+
485
+ // as well as creating the ghost element on the document body
486
+ this._appendGhost();
487
+
488
+ var touch = evt.touches ? evt.touches[0] : evt,
489
+ dx = touch.clientX - tapEvt.clientX,
490
+ dy = touch.clientY - tapEvt.clientY,
491
+ translate3d = evt.touches ? 'translate3d(' + dx + 'px,' + dy + 'px,0)' : 'translate(' + dx + 'px,' + dy + 'px)';
492
+
493
+ moved = true;
494
+ touchEvt = touch;
495
+
496
+ _css(ghostEl, 'webkitTransform', translate3d);
497
+ _css(ghostEl, 'mozTransform', translate3d);
498
+ _css(ghostEl, 'msTransform', translate3d);
499
+ _css(ghostEl, 'transform', translate3d);
500
+
501
+ evt.preventDefault();
502
+ }
503
+ },
504
+
505
+ _appendGhost: function () {
506
+ if (!ghostEl) {
507
+ var rect = dragEl.getBoundingClientRect(),
508
+ css = _css(dragEl),
509
+ options = this.options,
510
+ ghostRect;
511
+
512
+ ghostEl = dragEl.cloneNode(true);
513
+
514
+ _toggleClass(ghostEl, options.ghostClass, false);
515
+ _toggleClass(ghostEl, options.fallbackClass, true);
516
+
517
+ _css(ghostEl, 'top', rect.top - parseInt(css.marginTop, 10));
518
+ _css(ghostEl, 'left', rect.left - parseInt(css.marginLeft, 10));
519
+ _css(ghostEl, 'width', rect.width);
520
+ _css(ghostEl, 'height', rect.height);
521
+ _css(ghostEl, 'opacity', '0.8');
522
+ _css(ghostEl, 'position', 'fixed');
523
+ _css(ghostEl, 'zIndex', '100000');
524
+ _css(ghostEl, 'pointerEvents', 'none');
525
+
526
+ options.fallbackOnBody && document.body.appendChild(ghostEl) || rootEl.appendChild(ghostEl);
527
+
528
+ // Fixing dimensions.
529
+ ghostRect = ghostEl.getBoundingClientRect();
530
+ _css(ghostEl, 'width', rect.width * 2 - ghostRect.width);
531
+ _css(ghostEl, 'height', rect.height * 2 - ghostRect.height);
532
+ }
533
+ },
534
+
535
+ _onDragStart: function (/**Event*/evt, /**boolean*/useFallback) {
536
+ var dataTransfer = evt.dataTransfer,
537
+ options = this.options;
538
+
539
+ this._offUpEvents();
540
+
541
+ if (activeGroup.pull == 'clone') {
542
+ cloneEl = dragEl.cloneNode(true);
543
+ _css(cloneEl, 'display', 'none');
544
+ rootEl.insertBefore(cloneEl, dragEl);
545
+ }
546
+
547
+ if (useFallback) {
548
+
549
+ if (useFallback === 'touch') {
550
+ // Bind touch events
551
+ _on(document, 'touchmove', this._onTouchMove);
552
+ _on(document, 'touchend', this._onDrop);
553
+ _on(document, 'touchcancel', this._onDrop);
554
+ } else {
555
+ // Old brwoser
556
+ _on(document, 'mousemove', this._onTouchMove);
557
+ _on(document, 'mouseup', this._onDrop);
558
+ }
559
+
560
+ this._loopId = setInterval(this._emulateDragOver, 50);
561
+ }
562
+ else {
563
+ if (dataTransfer) {
564
+ dataTransfer.effectAllowed = 'move';
565
+ options.setData && options.setData.call(this, dataTransfer, dragEl);
566
+ }
567
+
568
+ _on(document, 'drop', this);
569
+ setTimeout(this._dragStarted, 0);
570
+ }
571
+ },
572
+
573
+ _onDragOver: function (/**Event*/evt) {
574
+ var el = this.el,
575
+ target,
576
+ dragRect,
577
+ revert,
578
+ options = this.options,
579
+ group = options.group,
580
+ groupPut = group.put,
581
+ isOwner = (activeGroup === group),
582
+ canSort = options.sort;
583
+
584
+ if (evt.preventDefault !== void 0) {
585
+ evt.preventDefault();
586
+ !options.dragoverBubble && evt.stopPropagation();
587
+ }
588
+
589
+ moved = true;
590
+
591
+ if (activeGroup && !options.disabled &&
592
+ (isOwner
593
+ ? canSort || (revert = !rootEl.contains(dragEl)) // Reverting item into the original list
594
+ : activeGroup.pull && groupPut && (
595
+ (activeGroup.name === group.name) || // by Name
596
+ (groupPut.indexOf && ~groupPut.indexOf(activeGroup.name)) // by Array
597
+ )
598
+ ) &&
599
+ (evt.rootEl === void 0 || evt.rootEl === this.el) // touch fallback
600
+ ) {
601
+ // Smart auto-scrolling
602
+ _autoScroll(evt, options, this.el);
603
+
604
+ if (_silent) {
605
+ return;
606
+ }
607
+
608
+ target = _closest(evt.target, options.draggable, el);
609
+ dragRect = dragEl.getBoundingClientRect();
610
+
611
+ if (revert) {
612
+ _cloneHide(true);
613
+
614
+ if (cloneEl || nextEl) {
615
+ rootEl.insertBefore(dragEl, cloneEl || nextEl);
616
+ }
617
+ else if (!canSort) {
618
+ rootEl.appendChild(dragEl);
619
+ }
620
+
621
+ return;
622
+ }
623
+
624
+
625
+ if ((el.children.length === 0) || (el.children[0] === ghostEl) ||
626
+ (el === evt.target) && (target = _ghostIsLast(el, evt))
627
+ ) {
628
+
629
+ if (target) {
630
+ if (target.animated) {
631
+ return;
632
+ }
633
+
634
+ targetRect = target.getBoundingClientRect();
635
+ }
636
+
637
+ _cloneHide(isOwner);
638
+
639
+ if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect) !== false) {
640
+ if (!dragEl.contains(el)) {
641
+ el.appendChild(dragEl);
642
+ parentEl = el; // actualization
643
+ }
644
+
645
+ this._animate(dragRect, dragEl);
646
+ target && this._animate(targetRect, target);
647
+ }
648
+ }
649
+ else if (target && !target.animated && target !== dragEl && (target.parentNode[expando] !== void 0)) {
650
+ if (lastEl !== target) {
651
+ lastEl = target;
652
+ lastCSS = _css(target);
653
+ lastParentCSS = _css(target.parentNode);
654
+ }
655
+
656
+
657
+ var targetRect = target.getBoundingClientRect(),
658
+ width = targetRect.right - targetRect.left,
659
+ height = targetRect.bottom - targetRect.top,
660
+ floating = /left|right|inline/.test(lastCSS.cssFloat + lastCSS.display)
661
+ || (lastParentCSS.display == 'flex' && lastParentCSS['flex-direction'].indexOf('row') === 0),
662
+ isWide = (target.offsetWidth > dragEl.offsetWidth),
663
+ isLong = (target.offsetHeight > dragEl.offsetHeight),
664
+ halfway = (floating ? (evt.clientX - targetRect.left) / width : (evt.clientY - targetRect.top) / height) > 0.5,
665
+ nextSibling = target.nextElementSibling,
666
+ moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect),
667
+ after
668
+ ;
669
+
670
+ if (moveVector !== false) {
671
+ _silent = true;
672
+ setTimeout(_unsilent, 30);
673
+
674
+ _cloneHide(isOwner);
675
+
676
+ if (moveVector === 1 || moveVector === -1) {
677
+ after = (moveVector === 1);
678
+ }
679
+ else if (floating) {
680
+ var elTop = dragEl.offsetTop,
681
+ tgTop = target.offsetTop;
682
+
683
+ if (elTop === tgTop) {
684
+ after = (target.previousElementSibling === dragEl) && !isWide || halfway && isWide;
685
+ } else {
686
+ after = tgTop > elTop;
687
+ }
688
+ } else {
689
+ after = (nextSibling !== dragEl) && !isLong || halfway && isLong;
690
+ }
691
+
692
+ if (!dragEl.contains(el)) {
693
+ if (after && !nextSibling) {
694
+ el.appendChild(dragEl);
695
+ } else {
696
+ target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
697
+ }
698
+ }
699
+
700
+ parentEl = dragEl.parentNode; // actualization
701
+
702
+ this._animate(dragRect, dragEl);
703
+ this._animate(targetRect, target);
704
+ }
705
+ }
706
+ }
707
+ },
708
+
709
+ _animate: function (prevRect, target) {
710
+ var ms = this.options.animation;
711
+
712
+ if (ms) {
713
+ var currentRect = target.getBoundingClientRect();
714
+
715
+ _css(target, 'transition', 'none');
716
+ _css(target, 'transform', 'translate3d('
717
+ + (prevRect.left - currentRect.left) + 'px,'
718
+ + (prevRect.top - currentRect.top) + 'px,0)'
719
+ );
720
+
721
+ target.offsetWidth; // repaint
722
+
723
+ _css(target, 'transition', 'all ' + ms + 'ms');
724
+ _css(target, 'transform', 'translate3d(0,0,0)');
725
+
726
+ clearTimeout(target.animated);
727
+ target.animated = setTimeout(function () {
728
+ _css(target, 'transition', '');
729
+ _css(target, 'transform', '');
730
+ target.animated = false;
731
+ }, ms);
732
+ }
733
+ },
734
+
735
+ _offUpEvents: function () {
736
+ var ownerDocument = this.el.ownerDocument;
737
+
738
+ _off(document, 'touchmove', this._onTouchMove);
739
+ _off(ownerDocument, 'mouseup', this._onDrop);
740
+ _off(ownerDocument, 'touchend', this._onDrop);
741
+ _off(ownerDocument, 'touchcancel', this._onDrop);
742
+ },
743
+
744
+ _onDrop: function (/**Event*/evt) {
745
+ var el = this.el,
746
+ options = this.options;
747
+
748
+ clearInterval(this._loopId);
749
+ clearInterval(autoScroll.pid);
750
+ clearTimeout(this._dragStartTimer);
751
+
752
+ // Unbind events
753
+ _off(document, 'mousemove', this._onTouchMove);
754
+
755
+ if (this.nativeDraggable) {
756
+ _off(document, 'drop', this);
757
+ _off(el, 'dragstart', this._onDragStart);
758
+ }
759
+
760
+ this._offUpEvents();
761
+
762
+ if (evt) {
763
+ if (moved) {
764
+ evt.preventDefault();
765
+ !options.dropBubble && evt.stopPropagation();
766
+ }
767
+
768
+ ghostEl && ghostEl.parentNode.removeChild(ghostEl);
769
+
770
+ if (dragEl) {
771
+ if (this.nativeDraggable) {
772
+ _off(dragEl, 'dragend', this);
773
+ }
774
+
775
+ _disableDraggable(dragEl);
776
+
777
+ // Remove class's
778
+ _toggleClass(dragEl, this.options.ghostClass, false);
779
+ _toggleClass(dragEl, this.options.chosenClass, false);
780
+
781
+ if (rootEl !== parentEl) {
782
+ newIndex = _index(dragEl, options.draggable);
783
+
784
+ if (newIndex >= 0) {
785
+ // drag from one list and drop into another
786
+ _dispatchEvent(null, parentEl, 'sort', dragEl, rootEl, oldIndex, newIndex);
787
+ _dispatchEvent(this, rootEl, 'sort', dragEl, rootEl, oldIndex, newIndex);
788
+
789
+ // Add event
790
+ _dispatchEvent(null, parentEl, 'add', dragEl, rootEl, oldIndex, newIndex);
791
+
792
+ // Remove event
793
+ _dispatchEvent(this, rootEl, 'remove', dragEl, rootEl, oldIndex, newIndex);
794
+ }
795
+ }
796
+ else {
797
+ // Remove clone
798
+ cloneEl && cloneEl.parentNode.removeChild(cloneEl);
799
+
800
+ if (dragEl.nextSibling !== nextEl) {
801
+ // Get the index of the dragged element within its parent
802
+ newIndex = _index(dragEl, options.draggable);
803
+
804
+ if (newIndex >= 0) {
805
+ // drag & drop within the same list
806
+ _dispatchEvent(this, rootEl, 'update', dragEl, rootEl, oldIndex, newIndex);
807
+ _dispatchEvent(this, rootEl, 'sort', dragEl, rootEl, oldIndex, newIndex);
808
+ }
809
+ }
810
+ }
811
+
812
+ if (Sortable.active) {
813
+ if (newIndex === null || newIndex === -1) {
814
+ newIndex = oldIndex;
815
+ }
816
+
817
+ _dispatchEvent(this, rootEl, 'end', dragEl, rootEl, oldIndex, newIndex);
818
+
819
+ // Save sorting
820
+ this.save();
821
+ }
822
+ }
823
+
824
+ }
825
+ this._nulling();
826
+ },
827
+
828
+ _nulling: function() {
829
+ // Nulling
830
+ rootEl =
831
+ dragEl =
832
+ parentEl =
833
+ ghostEl =
834
+ nextEl =
835
+ cloneEl =
836
+
837
+ scrollEl =
838
+ scrollParentEl =
839
+
840
+ tapEvt =
841
+ touchEvt =
842
+
843
+ moved =
844
+ newIndex =
845
+
846
+ lastEl =
847
+ lastCSS =
848
+
849
+ activeGroup =
850
+ Sortable.active = null;
851
+ },
852
+
853
+ handleEvent: function (/**Event*/evt) {
854
+ var type = evt.type;
855
+
856
+ if (type === 'dragover' || type === 'dragenter') {
857
+ if (dragEl) {
858
+ this._onDragOver(evt);
859
+ _globalDragOver(evt);
860
+ }
861
+ }
862
+ else if (type === 'drop' || type === 'dragend') {
863
+ this._onDrop(evt);
864
+ }
865
+ },
866
+
867
+
868
+ /**
869
+ * Serializes the item into an array of string.
870
+ * @returns {String[]}
871
+ */
872
+ toArray: function () {
873
+ var order = [],
874
+ el,
875
+ children = this.el.children,
876
+ i = 0,
877
+ n = children.length,
878
+ options = this.options;
879
+
880
+ for (; i < n; i++) {
881
+ el = children[i];
882
+ if (_closest(el, options.draggable, this.el)) {
883
+ order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
884
+ }
885
+ }
886
+
887
+ return order;
888
+ },
889
+
890
+
891
+ /**
892
+ * Sorts the elements according to the array.
893
+ * @param {String[]} order order of the items
894
+ */
895
+ sort: function (order) {
896
+ var items = {}, rootEl = this.el;
897
+
898
+ this.toArray().forEach(function (id, i) {
899
+ var el = rootEl.children[i];
900
+
901
+ if (_closest(el, this.options.draggable, rootEl)) {
902
+ items[id] = el;
903
+ }
904
+ }, this);
905
+
906
+ order.forEach(function (id) {
907
+ if (items[id]) {
908
+ rootEl.removeChild(items[id]);
909
+ rootEl.appendChild(items[id]);
910
+ }
911
+ });
912
+ },
913
+
914
+
915
+ /**
916
+ * Save the current sorting
917
+ */
918
+ save: function () {
919
+ var store = this.options.store;
920
+ store && store.set(this);
921
+ },
922
+
923
+
924
+ /**
925
+ * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
926
+ * @param {HTMLElement} el
927
+ * @param {String} [selector] default: `options.draggable`
928
+ * @returns {HTMLElement|null}
929
+ */
930
+ closest: function (el, selector) {
931
+ return _closest(el, selector || this.options.draggable, this.el);
932
+ },
933
+
934
+
935
+ /**
936
+ * Set/get option
937
+ * @param {string} name
938
+ * @param {*} [value]
939
+ * @returns {*}
940
+ */
941
+ option: function (name, value) {
942
+ var options = this.options;
943
+
944
+ if (value === void 0) {
945
+ return options[name];
946
+ } else {
947
+ options[name] = value;
948
+
949
+ if (name === 'group') {
950
+ _prepareGroup(options);
951
+ }
952
+ }
953
+ },
954
+
955
+
956
+ /**
957
+ * Destroy
958
+ */
959
+ destroy: function () {
960
+ var el = this.el;
961
+
962
+ el[expando] = null;
963
+
964
+ _off(el, 'mousedown', this._onTapStart);
965
+ _off(el, 'touchstart', this._onTapStart);
966
+
967
+ if (this.nativeDraggable) {
968
+ _off(el, 'dragover', this);
969
+ _off(el, 'dragenter', this);
970
+ }
971
+
972
+ // Remove draggable attributes
973
+ Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) {
974
+ el.removeAttribute('draggable');
975
+ });
976
+
977
+ touchDragOverListeners.splice(touchDragOverListeners.indexOf(this._onDragOver), 1);
978
+
979
+ this._onDrop();
980
+
981
+ this.el = el = null;
982
+ }
983
+ };
984
+
985
+
986
+ function _cloneHide(state) {
987
+ if (cloneEl && (cloneEl.state !== state)) {
988
+ _css(cloneEl, 'display', state ? 'none' : '');
989
+ !state && cloneEl.state && rootEl.insertBefore(cloneEl, dragEl);
990
+ cloneEl.state = state;
991
+ }
992
+ }
993
+
994
+
995
+ function _closest(/**HTMLElement*/el, /**String*/selector, /**HTMLElement*/ctx) {
996
+ if (el) {
997
+ ctx = ctx || document;
998
+
999
+ do {
1000
+ if (
1001
+ (selector === '>*' && el.parentNode === ctx)
1002
+ || _matches(el, selector)
1003
+ ) {
1004
+ return el;
1005
+ }
1006
+ }
1007
+ while (el !== ctx && (el = el.parentNode));
1008
+ }
1009
+
1010
+ return null;
1011
+ }
1012
+
1013
+
1014
+ function _globalDragOver(/**Event*/evt) {
1015
+ if (evt.dataTransfer) {
1016
+ evt.dataTransfer.dropEffect = 'move';
1017
+ }
1018
+ evt.preventDefault();
1019
+ }
1020
+
1021
+
1022
+ function _on(el, event, fn) {
1023
+ el.addEventListener(event, fn, false);
1024
+ }
1025
+
1026
+
1027
+ function _off(el, event, fn) {
1028
+ el.removeEventListener(event, fn, false);
1029
+ }
1030
+
1031
+
1032
+ function _toggleClass(el, name, state) {
1033
+ if (el) {
1034
+ if (el.classList) {
1035
+ el.classList[state ? 'add' : 'remove'](name);
1036
+ }
1037
+ else {
1038
+ var className = (' ' + el.className + ' ').replace(RSPACE, ' ').replace(' ' + name + ' ', ' ');
1039
+ el.className = (className + (state ? ' ' + name : '')).replace(RSPACE, ' ');
1040
+ }
1041
+ }
1042
+ }
1043
+
1044
+
1045
+ function _css(el, prop, val) {
1046
+ var style = el && el.style;
1047
+
1048
+ if (style) {
1049
+ if (val === void 0) {
1050
+ if (document.defaultView && document.defaultView.getComputedStyle) {
1051
+ val = document.defaultView.getComputedStyle(el, '');
1052
+ }
1053
+ else if (el.currentStyle) {
1054
+ val = el.currentStyle;
1055
+ }
1056
+
1057
+ return prop === void 0 ? val : val[prop];
1058
+ }
1059
+ else {
1060
+ if (!(prop in style)) {
1061
+ prop = '-webkit-' + prop;
1062
+ }
1063
+
1064
+ style[prop] = val + (typeof val === 'string' ? '' : 'px');
1065
+ }
1066
+ }
1067
+ }
1068
+
1069
+
1070
+ function _find(ctx, tagName, iterator) {
1071
+ if (ctx) {
1072
+ var list = ctx.getElementsByTagName(tagName), i = 0, n = list.length;
1073
+
1074
+ if (iterator) {
1075
+ for (; i < n; i++) {
1076
+ iterator(list[i], i);
1077
+ }
1078
+ }
1079
+
1080
+ return list;
1081
+ }
1082
+
1083
+ return [];
1084
+ }
1085
+
1086
+
1087
+
1088
+ function _dispatchEvent(sortable, rootEl, name, targetEl, fromEl, startIndex, newIndex) {
1089
+ var evt = document.createEvent('Event'),
1090
+ options = (sortable || rootEl[expando]).options,
1091
+ onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1);
1092
+
1093
+ evt.initEvent(name, true, true);
1094
+
1095
+ evt.to = rootEl;
1096
+ evt.from = fromEl || rootEl;
1097
+ evt.item = targetEl || rootEl;
1098
+ evt.clone = cloneEl;
1099
+
1100
+ evt.oldIndex = startIndex;
1101
+ evt.newIndex = newIndex;
1102
+
1103
+ rootEl.dispatchEvent(evt);
1104
+
1105
+ if (options[onName]) {
1106
+ options[onName].call(sortable, evt);
1107
+ }
1108
+ }
1109
+
1110
+
1111
+ function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect) {
1112
+ var evt,
1113
+ sortable = fromEl[expando],
1114
+ onMoveFn = sortable.options.onMove,
1115
+ retVal;
1116
+
1117
+ evt = document.createEvent('Event');
1118
+ evt.initEvent('move', true, true);
1119
+
1120
+ evt.to = toEl;
1121
+ evt.from = fromEl;
1122
+ evt.dragged = dragEl;
1123
+ evt.draggedRect = dragRect;
1124
+ evt.related = targetEl || toEl;
1125
+ evt.relatedRect = targetRect || toEl.getBoundingClientRect();
1126
+
1127
+ fromEl.dispatchEvent(evt);
1128
+
1129
+ if (onMoveFn) {
1130
+ retVal = onMoveFn.call(sortable, evt);
1131
+ }
1132
+
1133
+ return retVal;
1134
+ }
1135
+
1136
+
1137
+ function _disableDraggable(el) {
1138
+ el.draggable = false;
1139
+ }
1140
+
1141
+
1142
+ function _unsilent() {
1143
+ _silent = false;
1144
+ }
1145
+
1146
+
1147
+ /** @returns {HTMLElement|false} */
1148
+ function _ghostIsLast(el, evt) {
1149
+ var lastEl = el.lastElementChild,
1150
+ rect = lastEl.getBoundingClientRect();
1151
+
1152
+ return ((evt.clientY - (rect.top + rect.height) > 5) || (evt.clientX - (rect.right + rect.width) > 5)) && lastEl; // min delta
1153
+ }
1154
+
1155
+
1156
+ /**
1157
+ * Generate id
1158
+ * @param {HTMLElement} el
1159
+ * @returns {String}
1160
+ * @private
1161
+ */
1162
+ function _generateId(el) {
1163
+ var str = el.tagName + el.className + el.src + el.href + el.textContent,
1164
+ i = str.length,
1165
+ sum = 0;
1166
+
1167
+ while (i--) {
1168
+ sum += str.charCodeAt(i);
1169
+ }
1170
+
1171
+ return sum.toString(36);
1172
+ }
1173
+
1174
+ /**
1175
+ * Returns the index of an element within its parent for a selected set of
1176
+ * elements
1177
+ * @param {HTMLElement} el
1178
+ * @param {selector} selector
1179
+ * @return {number}
1180
+ */
1181
+ function _index(el, selector) {
1182
+ var index = 0;
1183
+
1184
+ if (!el || !el.parentNode) {
1185
+ return -1;
1186
+ }
1187
+
1188
+ while (el && (el = el.previousElementSibling)) {
1189
+ if (el.nodeName.toUpperCase() !== 'TEMPLATE'
1190
+ && _matches(el, selector)) {
1191
+ index++;
1192
+ }
1193
+ }
1194
+
1195
+ return index;
1196
+ }
1197
+
1198
+ function _matches(/**HTMLElement*/el, /**String*/selector) {
1199
+ if (el) {
1200
+ selector = selector.split('.');
1201
+
1202
+ var tag = selector.shift().toUpperCase(),
1203
+ re = new RegExp('\\s(' + selector.join('|') + ')(?=\\s)', 'g');
1204
+
1205
+ return (
1206
+ (tag === '' || el.nodeName.toUpperCase() == tag) &&
1207
+ (!selector.length || ((' ' + el.className + ' ').match(re) || []).length == selector.length)
1208
+ );
1209
+ }
1210
+
1211
+ return false;
1212
+ }
1213
+
1214
+ function _throttle(callback, ms) {
1215
+ var args, _this;
1216
+
1217
+ return function () {
1218
+ if (args === void 0) {
1219
+ args = arguments;
1220
+ _this = this;
1221
+
1222
+ setTimeout(function () {
1223
+ if (args.length === 1) {
1224
+ callback.call(_this, args[0]);
1225
+ } else {
1226
+ callback.apply(_this, args);
1227
+ }
1228
+
1229
+ args = void 0;
1230
+ }, ms);
1231
+ }
1232
+ };
1233
+ }
1234
+
1235
+ function _extend(dst, src) {
1236
+ if (dst && src) {
1237
+ for (var key in src) {
1238
+ if (src.hasOwnProperty(key)) {
1239
+ dst[key] = src[key];
1240
+ }
1241
+ }
1242
+ }
1243
+
1244
+ return dst;
1245
+ }
1246
+
1247
+
1248
+ // Export utils
1249
+ Sortable.utils = {
1250
+ on: _on,
1251
+ off: _off,
1252
+ css: _css,
1253
+ find: _find,
1254
+ is: function (el, selector) {
1255
+ return !!_closest(el, selector, el);
1256
+ },
1257
+ extend: _extend,
1258
+ throttle: _throttle,
1259
+ closest: _closest,
1260
+ toggleClass: _toggleClass,
1261
+ index: _index
1262
+ };
1263
+
1264
+
1265
+ /**
1266
+ * Create sortable instance
1267
+ * @param {HTMLElement} el
1268
+ * @param {Object} [options]
1269
+ */
1270
+ Sortable.create = function (el, options) {
1271
+ return new Sortable(el, options);
1272
+ };
1273
+
1274
+
1275
+ // Export
1276
+ Sortable.version = '1.4.2';
1277
+ return Sortable;
1278
+ });