1/**! 2 * Sortable 1.15.6 3 * @author RubaXa <[email protected]> 4 * @author owenm <[email protected]> 5 * @license MIT 6 */ 7 8/* global define, require, module */ 9( function( global, factory ) { 10 'use strict'; 11 if ( typeof exports === 'object' && typeof module !== 'undefined' ) { 12 module.exports = factory(); 13 } else if ( typeof define === 'function' && define.amd ) { 14 define( factory ); 15 } else { 16 global = global || self; 17 global.Sortable = factory(); 18 } 19}( this, ( function() { 20 'use strict'; 21 22 var version = '1.15.6'; 23 var IE11OrLess = userAgent( /(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i ); 24 var Edge = userAgent( /Edge/i ); 25 var FireFox = userAgent( /firefox/i ); 26 var Safari = userAgent( /safari/i ) && ! userAgent( /chrome/i ) && ! userAgent( /android/i ); 27 var IOS = userAgent( /iP(ad|od|hone)/i ); 28 var ChromeForAndroid = userAgent( /chrome/i ) && userAgent( /android/i ); 29 var captureMode = { 30 capture: false, 31 passive: false 32 }; 33 var R_SPACE = /\s+/g; 34 var _throttleTimeout; 35 var expando = 'Sortable' + new Date().getTime(); 36 var plugins = []; 37 var defaults = { 38 initializeByDefault: true 39 }; 40 var PluginManager = { 41 mount: function mount( plugin ) { 42 var option; 43 // Set default static properties 44 for ( option in defaults ) { 45 if ( defaults.hasOwnProperty( option ) && ! ( option in plugin ) ) { 46 plugin[ option ] = defaults[ option ]; 47 } 48 } 49 plugins.forEach( function( p ) { 50 if ( p.pluginName === plugin.pluginName ) { 51 throw 'Sortable: Cannot mount plugin '.concat( plugin.pluginName, ' more than once' ); 52 } 53 } ); 54 plugins.push( plugin ); 55 }, 56 pluginEvent: function pluginEvent( eventName, sortable, evt ) { 57 var _this = this; 58 var eventNameGlobal = eventName + 'Global'; 59 this.eventCanceled = false; 60 evt.cancel = function() { 61 _this.eventCanceled = true; 62 }; 63 plugins.forEach( function( plugin ) { 64 if ( ! sortable[ plugin.pluginName ] ) { 65 return; 66 } 67 // Fire global events if it exists in this sortable 68 if ( sortable[ plugin.pluginName ][ eventNameGlobal ] ) { 69 sortable[ plugin.pluginName ][ eventNameGlobal ]( _objectSpread2( { 70 sortable: sortable 71 }, evt ) ); 72 } 73 74 // Only fire plugin event if plugin is enabled in this sortable, 75 // and plugin has event defined 76 if ( sortable.options[ plugin.pluginName ] && sortable[ plugin.pluginName ][ eventName ] ) { 77 sortable[ plugin.pluginName ][ eventName ]( _objectSpread2( { 78 sortable: sortable 79 }, evt ) ); 80 } 81 } ); 82 }, 83 initializePlugins: function initializePlugins( sortable, el, _defaults ) { 84 var option; 85 var modified; 86 plugins.forEach( function( plugin ) { 87 var pluginName = plugin.pluginName; 88 var initialized; 89 if ( ! sortable.options[ pluginName ] && ! plugin.initializeByDefault ) { 90 return; 91 } 92 initialized = new plugin( sortable, el, sortable.options ); 93 initialized.sortable = sortable; 94 initialized.options = sortable.options; 95 sortable[ pluginName ] = initialized; 96 97 // Add default options from plugin 98 _extends( _defaults, initialized.defaults ); 99 } ); 100 for ( option in sortable.options ) { 101 if ( ! sortable.options.hasOwnProperty( option ) ) { 102 continue; 103 } 104 modified = this.modifyOption( sortable, option, sortable.options[ option ] ); 105 if ( typeof modified !== 'undefined' ) { 106 sortable.options[ option ] = modified; 107 } 108 } 109 }, 110 getEventProperties: function getEventProperties( name, sortable ) { 111 var eventProperties = {}; 112 plugins.forEach( function( plugin ) { 113 if ( typeof plugin.eventProperties !== 'function' ) { 114 return; 115 } 116 _extends( eventProperties, plugin.eventProperties.call( sortable[ plugin.pluginName ], name ) ); 117 } ); 118 return eventProperties; 119 }, 120 modifyOption: function modifyOption( sortable, name, value ) { 121 var modifiedValue; 122 plugins.forEach( function( plugin ) { 123 // Plugin must exist on the Sortable 124 if ( ! sortable[ plugin.pluginName ] ) { 125 return; 126 } 127 128 // If static option listener exists for this option, call in the context of the Sortable's instance of this plugin 129 if ( plugin.optionListeners && typeof plugin.optionListeners[ name ] === 'function' ) { 130 modifiedValue = plugin.optionListeners[ name ].call( sortable[ plugin.pluginName ], value ); 131 } 132 } ); 133 return modifiedValue; 134 } 135 }; 136 var _excluded = [ 'evt' ]; 137 var pluginEvent = function pluginEvent( eventName, sortable ) { 138 var _ref = arguments.length > 2 && arguments[ 2 ] !== undefined ? arguments[ 2 ] : {}, 139 originalEvent = _ref.evt, 140 data = _objectWithoutProperties( _ref, _excluded ); 141 PluginManager.pluginEvent.bind( Sortable )( eventName, sortable, _objectSpread2
141( { 142 dragEl: dragEl, 143 parentEl: parentEl, 144 ghostEl: ghostEl, 145 rootEl: rootEl, 146 nextEl: nextEl, 147 lastDownEl: lastDownEl, 148 cloneEl: cloneEl, 149 cloneHidden: cloneHidden, 150 dragStarted: moved, 151 putSortable: putSortable, 152 activeSortable: Sortable.active, 153 originalEvent: originalEvent, 154 oldIndex: oldIndex, 155 oldDraggableIndex: oldDraggableIndex, 156 newIndex: newIndex, 157 newDraggableIndex: newDraggableIndex, 158 hideGhostForTarget: _hideGhostForTarget, 159 unhideGhostForTarget: _unhideGhostForTarget, 160 cloneNowHidden: function cloneNowHidden() { 161 cloneHidden = true; 162 }, 163 cloneNowShown: function cloneNowShown() { 164 cloneHidden = false; 165 }, 166 dispatchSortableEvent: function dispatchSortableEvent( name ) { 167 _dispatchEvent( { 168 sortable: sortable, 169 name: name, 170 originalEvent: originalEvent 171 } ); 172 } 173 }, data ) ); 174 }; 175 var dragEl, 176 parentEl, 177 ghostEl, 178 rootEl, 179 nextEl, 180 lastDownEl, 181 cloneEl, 182 cloneHidden, 183 oldIndex, 184 newIndex, 185 oldDraggableIndex, 186 newDraggableIndex, 187 activeGroup, 188 putSortable, 189 awaitingDragStarted = false, 190 ignoreNextClick = false, 191 sortables = [], 192 tapEvt, 193 touchEvt, 194 lastDx, 195 lastDy, 196 tapDistanceLeft, 197 tapDistanceTop, 198 moved, 199 lastTarget, 200 lastDirection, 201 pastFirstInvertThresh = false, 202 isCircumstantialInvert = false, 203 targetMoveDistance, 204 // For positioning ghost absolutely 205 ghostRelativeParent, 206 ghostRelativeParentInitialScroll = [], 207 // (left, top) 208 209 _silent = false, 210 savedInputChecked = []; 211 212 var documentExists = typeof document !== 'undefined', 213 PositionGhostAbsolutely = IOS, 214 CSSFloatProperty = Edge || IE11OrLess ? 'cssFloat' : 'float', 215 // This will not pass for IE9, because IE9 DnD only works on anchors 216 supportDraggable = documentExists && ! ChromeForAndroid && ! IOS && 'draggable' in document.createElement( 'div' ), 217 supportCssPointerEvents = ( function() { 218 var el; 219 if ( ! documentExists ) { 220 return; 221 } 222 // false when <= IE11 223 if ( IE11OrLess ) { 224 return false; 225 } 226 el = document.createElement( 'x' ); 227 el.style.cssText = 'pointer-events:auto'; 228 return el.style.pointerEvents === 'auto'; 229 }() ), 230 _detectDirection = function _detectDirection( el, options ) { 231 var elCSS = css( el ), 232 elWidth = parseInt( elCSS.width, 10 ) - parseInt( elCSS.paddingLeft, 10 ) - parseInt( elCSS.paddingRight, 10 ) - parseInt( elCSS.borderLeftWidth, 10 ) - parseInt( elCSS.borderRightWidth, 10 ), 233 child1 = getChild( el, 0, options ), 234 child2 = getChild( el, 1, options ), 235 touchingSideChild2, 236 firstChildCSS = child1 && css( child1 ), 237 secondChildCSS = child2 && css( child2 ), 238 firstChildWidth = firstChildCSS && parseInt( firstChildCSS.marginLeft, 10 ) + parseInt( firstChildCSS.marginRight, 10 ) + getRect( child1 ).width, 239 secondChildWidth = secondChildCSS && parseInt( secondChildCSS.marginLeft, 10 ) + parseInt( secondChildCSS.marginRight, 10 ) + getRect( child2 ).width; 240 if ( elCSS.display === 'flex' ) { 241 return elCSS.flexDirection === 'column' || elCSS.flexDirection === 'column-reverse' ? 'vertical' : 'horizontal'; 242 } 243 if ( elCSS.display === 'grid' ) { 244 return elCSS.gridTemplateColumns.split( ' ' ).length <= 1 ? 'vertical' : 'horizontal'; 245 } 246 if ( child1 && firstChildCSS.float && firstChildCSS.float !== 'none' ) { 247 touchingSideChild2 = firstChildCSS.float === 'left' ? 'left' : 'right'; 248 return child2 && ( secondChildCSS.clear === 'both' || secondChildCSS.clear === touchingSideChild2 ) ? 'vertical' : 'horizontal'; 249 } 250 return child1 && ( firstChildCSS.display === 'block' || firstChildCSS.display === 'flex' || firstChildCSS.display === 'table' || firstChildCSS.display === 'grid' || firstChildWidth >= elWidth && elCSS[ CSSFloatProperty ] === 'none' || child2 && elCSS[ CSSFloatProperty ] === 'none' && firstChildWidth + secondChildWidth > elWidth ) ? 'vertical' : 'horizontal'; 251 }, 252 _dragElInRowColumn = function _dragElInRowColumn( dragRect, targetRect, vertical ) { 253 var dragElS1Opp = vertical ? dragRect.left : dragRect.top, 254 dragElS2Opp = vertical ? dragRect.right : dragRect.bottom, 255 dragElOppLength = vertical ? dragRect.width : dragRect.height, 256 targetS1Opp = vertical ? targetRect.left : targetRect.top, 257 targetS2Opp = vertical ? targetRect.right : targetRect.bottom, 258 targetOppLength = vertical ? targetRect.width : targetRect.height; 259 return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2; 260 }, 261 /** 262 * Detects first nearest empty sortable to X and Y position using emptyInsertThreshold. 263 * @param {number} x X position 264 * @param {number} y Y position 265 * @return {HTMLElement} Element of the first found nearest Sortable 266 */ 267 _detectNearestEmptySortable = function _detectNearestEmptySortable( x, y ) { 268 var ret; 269 sortables.some( function( sortable ) { 270 var threshold = sortable[ expando ].options.emptyInsertThreshold; 271 var rect; 272 var insideHorizontally; 273 var insideVertically; 274 if ( ! threshold || lastChild( sortable ) ) { 275 return false; // Explicitly continue searching 276 } 277 rect = getRect( sortable ); 278 insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold; 279 insideVertically = y >
279= rect.top - threshold && y <= rect.bottom + threshold; 280 if ( insideHorizontally && insideVertically ) { 281 ret = sortable; // Store the matched sortable 282 return true; // Stop iteration (found a match) 283 } 284 return false; // Continue searching 285 } ); 286 return ret; 287 }, 288 _prepareGroup = function _prepareGroup( options ) { 289 var group = {}; 290 var originalGroup = options.group; 291 function toFn( value, pull ) { 292 return function( to, from, _dragEl, evt ) { 293 var otherGroup; 294 var sameGroup = to.options.group.name && from.options.group.name && to.options.group.name === from.options.group.name; 295 if ( ( value === null || value === undefined ) && ( pull || sameGroup ) ) { 296 // Default pull value 297 // Default pull and put value if same group 298 return true; 299 } else if ( value === null || value === undefined || value === false ) { 300 return false; 301 } else if ( pull && value === 'clone' ) { 302 return value; 303 } else if ( typeof value === 'function' ) { 304 return toFn( value( to, from, _dragEl, evt ), pull )( to, from, _dragEl, evt ); 305 } 306 otherGroup = ( pull ? to : from ).options.group.name; 307 return ( value === true ) || ( typeof value === 'string' && value === otherGroup ) || ( value.join && value.indexOf( otherGroup ) > -1 ); 308 }; 309 } 310 if ( ! originalGroup || typeof originalGroup !== 'object' ) { 311 originalGroup = { 312 name: originalGroup 313 }; 314 } 315 group.name = originalGroup.name; 316 group.checkPull = toFn( originalGroup.pull, true ); 317 group.checkPut = toFn( originalGroup.put ); 318 group.revertClone = originalGroup.revertClone; 319 options.group = group; 320 }, 321 _hideGhostForTarget = function _hideGhostForTarget() { 322 if ( ! supportCssPointerEvents && ghostEl ) { 323 css( ghostEl, 'display', 'none' ); 324 } 325 }, 326 _unhideGhostForTarget = function _unhideGhostForTarget() { 327 if ( ! supportCssPointerEvents && ghostEl ) { 328 css( ghostEl, 'display', '' ); 329 } 330 }; 331 var autoScrolls = [], 332 scrollEl, 333 scrollRootEl, 334 scrolling = false, 335 lastAutoScrollX, 336 lastAutoScrollY, 337 touchEvt$1, 338 pointerElemChangedInterval; 339 var autoScroll = throttle( function( evt, options, _rootEl, isFallback ) { 340 var x; 341 var y; 342 var sens; 343 var speed; 344 var winScroller; 345 var scrollThisInstance; 346 var scrollCustomFn; 347 var layersOut; 348 var currentParent; 349 var el, rect, 350 top, 351 bottom, 352 left, 353 right, 354 width, 355 height, 356 canScrollX, 357 canScrollY, 358 scrollWidth, 359 scrollHeight, 360 elCSS, 361 scrollPosX, 362 scrollPosY, 363 vx, 364 vy, 365 i, 366 scrollOffsetY, 367 scrollOffsetX; 368 // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521 369 if ( ! options.scroll ) { 370 return; 371 } 372 x = ( evt.touches ? evt.touches[ 0 ] : evt ).clientX; 373 y = ( evt.touches ? evt.touches[ 0 ] : evt ).clientY; 374 sens = options.scrollSensitivity; 375 speed = options.scrollSpeed; 376 winScroller = getWindowScrollingElement(); 377 scrollThisInstance = false; 378 layersOut = 0; 379 currentParent = scrollEl; 380 381 // New scroll root, set scrollEl 382 if ( scrollRootEl !== _rootEl ) { 383 scrollRootEl = _rootEl; 384 clearAutoScrolls(); 385 scrollEl = options.scroll; 386 scrollCustomFn = options.scrollFn; 387 if ( scrollEl === true ) { 388 scrollEl = getParentAutoScrollElement( _rootEl, true ); 389 } 390 } 391 do { 392 el = currentParent; 393 if ( ! el ) { 394 continue; 395 } 396 rect = getRect( el ); 397 top = rect.top; 398 bottom = rect.bottom; 399 left = rect.left; 400 right = rect.right; 401 width = rect.width; 402 height = rect.height; 403 canScrollX = void 0; 404 canScrollY = void 0; 405 scrollWidth = el.scrollWidth; 406 scrollHeight = el.scrollHeight; 407 elCSS = css( el ); 408 scrollPosX = el.scrollLeft; 409 scrollPosY = el.scrollTop; 410 if ( el === winScroller ) { 411 canScrollX = width < scrollWidth && ( elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll' || elCSS.overflowX === 'visible' ); 412 canScrollY = height < scrollHeight && ( elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll' || elCSS.overflowY === 'visible' ); 413 } else { 414 canScrollX = width < scrollWidth && ( elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll' ); 415 canScrollY = height < scrollHeight && ( elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll' ); 416 } 417 vx = canScrollX && ( Math.abs( right - x ) <= sens && scrollPosX + width < scrollWidth ) - ( Math.abs( left - x ) <= sens && !! scrollPosX ); 418 vy = canScrollY && ( Math.abs( bottom - y ) <= sens && scrollPosY + height < scrollHeight ) - ( Math.abs( top - y ) <= sens && !! scrollPosY ); 419 if ( ! autoScrolls[ layersOut ] ) { 420 for ( i = 0; i <= layersOut; i++ ) { 421 if ( ! autoScrolls[ i ] ) { 422 autoScrolls[ i ] = {}; 423 } 424 } 425 } 426 if ( autoScrolls[ layersOut ].vx != vx || autoScrolls[ layersOut ].vy != vy || autoScrolls[ layersOut ].el !== el ) { 427 autoScrolls[ layersOut ].el = el; 428 autoScrolls[ layersOut ].vx = vx; 429 autoScrolls[ layersOut ].vy = vy; 430 clearInterval( autoScrolls[ layersOut ].pid ); 431 if ( vx !== 0 || vy !== 0 ) { 432 scrollThisInstance = true; 433 autoScrolls[ layersOut ].pid = setInterval( function() { 434 // emulate drag over during autoscroll (fallback), emulating native DnD behaviour 435 if ( isFallback && this.layer === 0 ) { 436 Sortable.active._onTouchMove( touchEvt$1 ); // To move ghost if it is positioned absolutely 437 } 438 scrollOffsetY = autoScrolls[ this.layer ].vy ? autoScrolls[ this.layer ].vy * speed : 0; 439 scrollOffsetX = autoScrolls[ this.layer ].vx ? autoScrolls[ this.layer ].vx * speed : 0; 440 if ( typeof scrollCustomFn === 'function' ) { 441 if ( scrollCustomFn.call( Sortable.dragged.parentNode[ expando ], scrollOffsetX, scrollOffsetY, evt, touchEvt$1, autoScrolls[ this.layer ].el ) !== 'continue' ) { 442 return; 443 } 444 } 445 scrollBy( autoScrolls[ this.layer ].el, scrollOffsetX, scrollOffsetY ); 446 }.bind( { 447 layer: layersOut 448 } ), 24 ); 449 } 450 } 451 layersOut++; 452 } while ( options.bubbleScroll && currentParent !== winScroller && ( currentParent = getParentAutoScrollElement( currentParent, false ) ) ); 453 scrolling = scrollThisInstance; // in case another function catches scrolling as false in between when it is not 454 }, 30 ); 455 456 var drop = function drop( _ref ) { 457 var originalEvent = _ref.originalEvent, 458 _putSortable = _ref.putSortable, 459 _dragEl = _ref.dragEl, 460 activeSortable = _ref.activeSortable, 461 dispatchSortableEvent = _ref.dispatchSortableEvent, 462 hideGhostForTarget = _ref.hideGhostForTarget, 463 unhideGhostForTarget = _ref.unhideGhostForTarget; 464 var toSortable; 465 var touch; 466 var target; 467 if ( ! originalEvent ) { 468 return; 469 } 470 toSortable = _putSortable || activeSortable; 471 hideGhostForTarget(); 472 touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[ 0 ] : originalEvent; 473 target = document.elementFromPoint( touch.clientX, touch.clientY ); 474 unhideGhostForTarget(); 475 if ( toSortable && ! toSortable.el.contains( target ) ) { 476 dispatchSortableEvent( 'spill' ); 477 this.onSpill( { 478 dragEl: _dragEl, 479 putSortable: _putSortable 480 } ); 481 } 482 }; 483 var lastSwapEl; 484 var multiDragElements = [], 485 multiDragClones = [], 486 lastMultiDragSelect, 487 // for selection with modifier key down (SHIFT) 488 multiDragSortable, 489 initialFolding = false, 490 // Initial multi-drag fold when drag started 491 folding = false, 492 // Folding any other time 493 dragStarted = false, 494 dragEl$1, 495 clonesFromRect, 496 clonesHidden; 497 var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent( evt ) { 498 var nearest; 499 var event; 500 var i; 501 if ( dragEl ) { 502 evt = evt.touches ? evt.touches[ 0 ] : evt; 503 nearest = _detectNearestEmptySortable( evt.clientX, evt.clientY ); 504 if ( nearest ) { 505 // Create imitation event 506 event = {}; 507 for ( i in evt ) { 508 if ( evt.hasOwnProperty( i ) ) { 509 event[ i ] = evt[ i ]; 510 } 511 } 512 event.target = event.rootEl = nearest; 513 event.preventDefault = void 0; 514 event.stopPropagation = void 0; 515 nearest[ expando ]._onDragOver( event ); 516 } 517 } 518 }; 519 var _checkOutsideTargetEl = function _checkOutsideTargetEl( evt ) { 520 if ( dragEl ) { 521 dragEl.parentNode[ expando ]._isOutsideThisEl( evt.target ); 522 } 523 }; 524 function ownKeys( object, enumerableOnly ) { 525 var keys = Object.keys( object ); 526 var symbols; 527 if ( Object.getOwnPropertySymbols ) { 528 symbols = Object.getOwnPropertySymbols( object ); 529 if ( enumerableOnly ) { 530 symbols = symbols.filter( function( sym ) { 531 return Object.getOwnPropertyDescriptor( object, sym ).enumerable; 532 } ); 533 } 534 keys.push.apply( keys, symbols ); 535 } 536 return keys; 537 }
538 function _objectSpread2( target ) { 539 var i, source; 540 for ( i = 1; i < arguments.length; i++ ) { 541 source = ( arguments[ i ] !== undefined && arguments[ i ] !== null ) ? arguments[ i ] : {}; 542 if ( i % 2 ) { 543 ownKeys( Object( source ), true ).forEach( function( key ) { 544 _defineProperty( target, key, source[ key ] ); 545 } ); 546 } else if ( Object.getOwnPropertyDescriptors ) { 547 Object.defineProperties( target, Object.getOwnPropertyDescriptors( source ) ); 548 } else { 549 ownKeys( Object( source ) ).forEach( function( key ) { 550 Object.defineProperty( target, key, Object.getOwnPropertyDescriptor( source, key ) ); 551 } ); 552 } 553 } 554 return target; 555 } 556 557 function _defineProperty( obj, key, value ) { 558 if ( key in obj ) { 559 Object.defineProperty( obj, key, { 560 value: value, 561 enumerable: true, 562 configurable: true, 563 writable: true 564 } ); 565 } else { 566 obj[ key ] = value; 567 } 568 return obj; 569 } 570 function _extends() { 571 var i; 572 var source; 573 var key; 574 _extends = Object.assign || function( target ) { 575 for ( i = 1; i < arguments.length; i++ ) { 576 source = arguments[ i ]; 577 for ( key in source ) { 578 if ( Object.prototype.hasOwnProperty.call( source, key ) ) { 579 target[ key ] = source[ key ]; 580 } 581 } 582 } 583 return target; 584 }; 585 return _extends.apply( this, arguments ); 586 } 587 function _objectWithoutPropertiesLoose( source, excluded ) { 588 var target; 589 var sourceKeys; 590 var key, i; 591 if ( source == null ) { 592 return {}; 593 } 594 target = {}; 595 sourceKeys = Object.keys( source ); 596 for ( i = 0; i < sourceKeys.length; i++ ) { 597 key = sourceKeys[ i ]; 598 if ( excluded.indexOf( key ) >= 0 ) { 599 continue; 600 } 601 target[ key ] = source[ key ]; 602 } 603 return target; 604 } 605 function _objectWithoutProperties( source, excluded ) { 606 var target; 607 var key, i; 608 var sourceSymbolKeys; 609 if ( source == null ) { 610 return {}; 611 } 612 target = _objectWithoutPropertiesLoose( source, excluded ); 613 if ( Object.getOwnPropertySymbols ) { 614 sourceSymbolKeys = Object.getOwnPropertySymbols( source ); 615 for ( i = 0; i < sourceSymbolKeys.length; i++ ) { 616 key = sourceSymbolKeys[ i ]; 617 if ( excluded.indexOf( key ) >= 0 ) { 618 continue; 619 } 620 if ( ! Object.prototype.propertyIsEnumerable.call( source, key ) ) { 621 continue; 622 } 623 target[ key ] = source[ key ]; 624 } 625 } 626 return target; 627 } 628 function _toConsumableArray( arr ) { 629 return _arrayWithoutHoles( arr ) || _iterableToArray( arr ) || _unsupportedIterableToArray( arr ) || _nonIterableSpread(); 630 } 631 function _arrayWithoutHoles( arr ) { 632 if ( Array.isArray( arr ) ) { 633 return _arrayLikeToArray( arr ); 634 } 635 } 636 function _iterableToArray( iter ) { 637 if ( iter !== undefined && iter !== null && typeof iter[ Symbol.iterator ] === 'function' ) { 638 return Array.from( iter ); 639 } 640 } 641 function _unsupportedIterableToArray( o, minLen ) { 642 var n; 643 if ( ! o ) { 644 return; 645 } 646 if ( typeof o === 'string' ) { 647 return _arrayLikeToArray( o, minLen ); 648 } 649 n = Object.prototype.toString.call( o ).slice( 8, -1 ); 650 if ( n === 'Object' && o.constructor ) { 651 n = o.constructor.name; 652 } 653 if ( n === 'Map' || n === 'Set' ) { 654 return Array.from( o ); 655 } 656 if ( n === 'Arguments' || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test( n ) ) { 657 return _arrayLikeToArray( o, minLen ); 658 } 659 } 660 function _arrayLikeToArray( arr, len ) { 661 var i; 662 var arr2; 663 if ( len === undefined || len === null || len > arr.length ) { 664 len = arr.length; 665 } 666 arr2 = new Array( len ); 667 for ( i = 0; i < len; i++ ) { 668 arr2[ i ] = arr[ i ]; 669 } 670 return arr2; 671 } 672 function _nonIterableSpread() { 673 throw new TypeError( 'Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.' ); 674 } 675 676 function userAgent( pattern ) { 677 if ( typeof window !== 'undefined' && window.navigator ) { 678 return !! /*@__PURE__*/navigator.userAgent.match( pattern ); 679 } 680 } 681 function on( el, event, fn ) { 682 el.addEventListener( event, fn, ! IE11OrLess && captureMode ); 683 } 684 function off( el, event, fn ) { 685 el.removeEventListener( event, fn, ! IE11OrLess && captureMode ); 686 } 687 function matches( /**HTMLElement*/el, /**String*/selector ) { 688 if ( ! selector ) { 689 return; 690 } 691 if ( selector[ 0 ] === '>' ) { 692 selector = selector.substring( 1 ); 693 } 694 if ( el ) { 695 try { 696 if ( el.matches ) { 697 return el.matches( selector ); 698 } else if ( el.msMatchesSelector ) { 699 return el.msMatchesSelector( selector ); 700 } else if ( el.webkitMatchesSelector ) { 701 return el.webkitMatchesSelector( selector ); 702 } 703 } catch ( _ ) { 704 return false;
vendor: 6,340 bytes, lines 705-889
705 } 706 } 707 return false; 708 } 709 function getParentOrHost( el ) { 710 return el.host && el !== document && el.host.nodeType ? el.host : el.parentNode; 711 } 712 function closest( /**HTMLElement*/el, /**String*/selector, /**HTMLElement*/ctx, includeCTX ) { 713 if ( el ) { 714 ctx = ctx || document; 715 do { 716 if ( ( selector !== undefined && selector !== null && ( selector[ 0 ] === '>' ? el.parentNode === ctx && matches( el, selector ) : matches( el, selector ) ) ) || ( includeCTX && el === ctx ) ) { 717 return el; 718 } 719 if ( el === ctx ) { 720 break; 721 } 722 } while ( ( el = getParentOrHost( el ) ) ); 723 } 724 return null; 725 } 726 function toggleClass( el, name, state ) { 727 var className; 728 if ( el && name ) { 729 if ( el.classList ) { 730 el.classList[ state ? 'add' : 'remove' ]( name ); 731 } else { 732 className = ( ' ' + el.className + ' ' ).replace( R_SPACE, ' ' ).replace( ' ' + name + ' ', ' ' ); 733 el.className = ( className + ( state ? ' ' + name : '' ) ).replace( R_SPACE, ' ' ); 734 } 735 } 736 } 737 function css( el, prop, val ) { 738 var style = el && el.style; 739 if ( style ) { 740 if ( val === void 0 ) { 741 if ( document.defaultView && document.defaultView.getComputedStyle ) { 742 val = document.defaultView.getComputedStyle( el, '' ); 743 } else if ( el.currentStyle ) { 744 val = el.currentStyle; 745 } 746 return prop === void 0 ? val : val[ prop ]; 747 } 748 if ( ! ( prop in style ) && prop.indexOf( 'webkit' ) === -1 ) { 749 prop = '-webkit-' + prop; 750 } 751 style[ prop ] = val + ( typeof val === 'string' ? '' : 'px' ); 752 } 753 } 754 function matrix( el, selfOnly ) { 755 var appliedTransforms = ''; 756 var transform; 757 var matrixFn; 758 if ( typeof el === 'string' ) { 759 appliedTransforms = el; 760 } else { 761 do { 762 transform = css( el, 'transform' ); 763 if ( transform && transform !== 'none' ) { 764 appliedTransforms = transform + ' ' + appliedTransforms; 765 } 766 } while ( ! selfOnly && ( el = el.parentNode ) ); 767 } 768 matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix; 769 return matrixFn && new matrixFn( appliedTransforms ); 770 } 771 function find( ctx, tagName, iterator ) { 772 if ( ctx ) { 773 var list = ctx.getElementsByTagName( tagName ), 774 i = 0, 775 n = list.length; 776 if ( iterator ) { 777 for ( ; i < n; i++ ) { 778 iterator( list[ i ], i ); 779 } 780 } 781 return list; 782 } 783 return []; 784 } 785 function getWindowScrollingElement() { 786 var scrollingElement = document.scrollingElement; 787 if ( scrollingElement ) { 788 return scrollingElement; 789 } 790 return document.documentElement; 791 } 792 793 /** 794 * Returns the "bounding client rect" of given element 795 * @param {HTMLElement} el The element whose boundingClientRect is wanted 796 * @param {[boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container 797 * @param {[boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr 798 * @param {[boolean]} undoScale Whether the container's scale() should be undone 799 * @param {[HTMLElement]} container The parent the element will be placed in 800 * @return {Object} The boundingClientRect of el, with specified adjustments 801 */ 802 function getRect( el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container ) { 803 if ( ! el || ( ! el.getBoundingClientRect && el !== window ) ) { 804 return; 805 } 806 var elRect, top, left, bottom, right, height, width; 807 if ( el !== window && el.parentNode && el !== getWindowScrollingElement() ) { 808 elRect = el.getBoundingClientRect(); 809 top = elRect.top; 810 left = elRect.left; 811 bottom = elRect.bottom; 812 right = elRect.right; 813 height = elRect.height; 814 width = elRect.width; 815 } else { 816 top = 0; 817 left = 0; 818 bottom = window.innerHeight; 819 right = window.innerWidth; 820 height = window.innerHeight; 821 width = window.innerWidth; 822 } 823 if ( ( relativeToContainingBlock || relativeToNonStaticParent ) && el !== window ) { 824 // Adjust for translate() 825 container = container || el.parentNode; 826 827 // solves #1123 (see: https://stackoverflow.com/a/37953806/6088312) 828 // Not needed on <= IE11 829 if ( ! IE11OrLess ) { 830 do { 831 if ( container && container.getBoundingClientRect && ( css( container, 'transform' ) !== 'none' || relativeToNonStaticParent && css( container, 'position' ) !== 'static' ) ) { 832 var containerRect = container.getBoundingClientRect(); 833 834 // Set relative to edges of padding box of container 835 top -= containerRect.top + parseInt( css( container, 'border-top-width' ), 10 ); 836 left -= containerRect.left + parseInt( css( container, 'border-left-width' ), 10 ); 837 bottom = top + elRect.height; 838 right = left + elRect.width; 839 break; 840 } 841 } while ( container = container.parentNode ); 842 } 843 } 844 if ( undoScale && el !== window ) { 845 // Adjust for scale() 846 var elMatrix = matrix( container || el ), 847 scaleX = elMatrix && elMatrix.a, 848 scaleY = elMatrix && elMatrix.d; 849 if ( elMatrix ) { 850 top /= scaleY; 851 left /= scaleX; 852 width /= scaleX; 853 height /= scaleY; 854 bottom = top + height; 855 right = left + width; 856 } 857 } 858 return { 859 top: top, 860 left: left, 861 bottom: bottom, 862 right: right, 863 width: width, 864 height: height 865 }; 866 } 867 868 /** 869 * Checks if a side of an element is scrolled past a side of its parents 870 * @param {HTMLElement} el The element who's side being scrolled out of view is in question 871 * @param {string} elSide Side of the element in question ('top', 'left', 'right', 'bottom') 872 * @param {string} parentSide Side of the parent in question ('top', 'left', 'right', 'bottom') 873 * @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element 874 */ 875 function isScrolledPast( el, elSide, parentSide ) { 876 var parent = getParentAutoScrollElement( el, true ), 877 elSideVal = getRect( el )[ elSide ]; 878 879 while ( parent ) { 880 var parentSideVal = getRect( parent )[ parentSide ], 881 visible = void 0; 882 if ( parentSide === 'top' || parentSide === 'left' ) { 883 visible = elSideVal >= parentSideVal; 884 } else { 885 visible = elSideVal <= parentSideVal; 886 } 887 if ( ! visible ) { 888 return parent; 889 }
vendor: 7,500 bytes, lines 890-1114
890 if ( parent === getWindowScrollingElement() ) { 891 break; 892 } 893 parent = getParentAutoScrollElement( parent, false ); 894 } 895 return false; 896 } 897 898 /** 899 * Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible) 900 * and non-draggable elements 901 * @param {HTMLElement} el The parent element 902 * @param {number} childNum The index of the child 903 * @param {Object} options Parent Sortable's options 904 * @param {boolean} [includeDragEl=false] - If `true`, includes the dragged element in the search. 905 * @return {HTMLElement} The child at index childNum, or null if not found 906 */ 907 function getChild( el, childNum, options, includeDragEl ) { 908 var currentChild = 0, 909 i = 0, 910 children = el.children; 911 while ( i < children.length ) { 912 if ( children[ i ].style.display !== 'none' && children[ i ] !== Sortable.ghost && ( includeDragEl || children[ i ] !== Sortable.dragged ) && closest( children[ i ], options.draggable, el, false ) ) { 913 if ( currentChild === childNum ) { 914 return children[ i ]; 915 } 916 currentChild++; 917 } 918 i++; 919 } 920 return null; 921 } 922 923 /** 924 * Gets the last child in the el, ignoring ghostEl or invisible elements (clones) 925 * @param {HTMLElement} el Parent element 926 * @param {selector} selector Any other elements that should be ignored 927 * @return {HTMLElement} The last child, ignoring ghostEl 928 */ 929 function lastChild( el, selector ) { 930 var last = el.lastElementChild; 931 while ( last && ( last === Sortable.ghost || css( last, 'display' ) === 'none' || selector && ! matches( last, selector ) ) ) { 932 last = last.previousElementSibling; 933 } 934 return last || null; 935 } 936 937 /** 938 * Returns the index of an element within its parent for a selected set of 939 * elements 940 * @param {HTMLElement} el 941 * @param {selector} selector 942 * @return {number} 943 */ 944 function index( el, selector ) { 945 var _index = 0; 946 if ( ! el || ! el.parentNode ) { 947 return -1; 948 } 949 950 while ( ( el = el.previousElementSibling ) ) { 951 if ( el.nodeName.toUpperCase() !== 'TEMPLATE' && el !== Sortable.clone && ( ! selector || matches( el, selector ) ) ) { 952 _index++; 953 } 954 } 955 return _index; 956 } 957 958 /** 959 * Returns the scroll offset of the given element, added with all the scroll offsets of parent elements. 960 * The value is returned in real pixels. 961 * @param {HTMLElement} el 962 * @return {Array} Offsets in the format of [left, top] 963 */ 964 function getRelativeScrollOffset( el ) { 965 var offsetLeft = 0, 966 offsetTop = 0, 967 winScroller = getWindowScrollingElement(); 968 if ( el ) { 969 do { 970 var elMatrix = matrix( el ), 971 scaleX = elMatrix.a, 972 scaleY = elMatrix.d; 973 offsetLeft += el.scrollLeft * scaleX; 974 offsetTop += el.scrollTop * scaleY; 975 } while ( el !== winScroller && ( el = el.parentNode ) ); 976 } 977 return [ offsetLeft, offsetTop ]; 978 } 979 980 /** 981 * Returns the index of the object within the given array 982 * @param {Array} arr Array that may or may not hold the object 983 * @param {Object} obj An object that has a key-value pair unique to and identical to a key-value pair in the object you want to find 984 * @return {number} The index of the object in the array, or -1 985 */ 986 function indexOfObject( arr, obj ) { 987 for ( var i in arr ) { 988 if ( ! arr.hasOwnProperty( i ) ) { 989 continue; 990 } 991 for ( var key in obj ) { 992 if ( obj.hasOwnProperty( key ) && obj[ key ] === arr[ i ][ key ] ) { 993 return Number( i ); 994 } 995 } 996 } 997 return -1; 998 } 999 function getParentAutoScrollElement( el, includeSelf ) { 1000 // skip to window 1001 if ( ! el || ! el.getBoundingClientRect ) { 1002 return getWindowScrollingElement(); 1003 } 1004 var elem = el; 1005 var gotSelf = false; 1006 do { 1007 // we don't need to get elem css if it isn't even overflowing in the first place (performance) 1008 if ( elem.clientWidth < elem.scrollWidth || elem.clientHeight < elem.scrollHeight ) { 1009 var elemCSS = css( elem ); 1010 if ( elem.clientWidth < elem.scrollWidth && ( elemCSS.overflowX == 'auto' || elemCSS.overflowX == 'scroll' ) || elem.clientHeight < elem.scrollHeight && ( elemCSS.overflowY == 'auto' || elemCSS.overflowY == 'scroll' ) ) { 1011 if ( ! elem.getBoundingClientRect || elem === document.body ) { 1012 return getWindowScrollingElement(); 1013 } 1014 if ( gotSelf || includeSelf ) { 1015 return elem; 1016 } 1017 gotSelf = true; 1018 } 1019 } 1020 } while ( ( elem = elem.parentNode ) ); 1021 return getWindowScrollingElement(); 1022 } 1023 function extend( dst, src ) { 1024 var key; 1025 if ( dst && src ) { 1026 for ( key in src ) { 1027 if ( src.hasOwnProperty( key ) ) { 1028 dst[ key ] = src[ key ]; 1029 } 1030 } 1031 } 1032 return dst; 1033 } 1034 function isRectEqual( rect1, rect2 ) { 1035 return Math.round( rect1.top ) === Math.round( rect2.top ) && Math.round( rect1.left ) === Math.round( rect2.left ) && Math.round( rect1.height ) === Math.round( rect2.height ) && Math.round( rect1.width ) === Math.round( rect2.width ); 1036 } 1037 function throttle( callback, ms ) { 1038 return function() { 1039 var args = arguments, 1040 _this = this; 1041 if ( ! _throttleTimeout ) { 1042 if ( args.length === 1 ) { 1043 callback.call( _this, args[ 0 ] ); 1044 } else { 1045 callback.apply( _this, args ); 1046 } 1047 _throttleTimeout = setTimeout( function() { 1048 _throttleTimeout = void 0; 1049 }, ms ); 1050 } 1051 }; 1052 } 1053 function cancelThrottle() { 1054 clearTimeout( _throttleTimeout ); 1055 _throttleTimeout = void 0; 1056 } 1057 function scrollBy( el, x, y ) { 1058 el.scrollLeft += x; 1059 el.scrollTop += y; 1060 } 1061 function clone( el ) { 1062 var Polymer = window.Polymer; 1063 var $ = window.jQuery || window.Zepto; 1064 if ( Polymer && Polymer.dom ) { 1065 return Polymer.dom( el ).cloneNode( true ); 1066 } else if ( $ ) { 1067 return $( el ).clone( true )[ 0 ]; 1068 } 1069 return el.cloneNode( true ); 1070 } 1071 function setRect( el, rect ) { 1072 css( el, 'position', 'absolute' ); 1073 css( el, 'top', rect.top ); 1074 css( el, 'left', rect.left ); 1075 css( el, 'width', rect.width ); 1076 css( el, 'height', rect.height ); 1077 } 1078 function unsetRect( el ) { 1079 css( el, 'position', '' ); 1080 css( el, 'top', '' ); 1081 css( el, 'left', '' ); 1082 css( el, 'width', '' ); 1083 css( el, 'height', '' ); 1084 } 1085 function getChildContainingRectFromElement( container, options, ghostEl ) { 1086 var rect = {}; 1087 Array.from( container.children ).forEach( function( child ) { 1088 var _rect$left, _rect$top, _rect$right, _rect$bottom; 1089 if ( ! closest( child, options.draggable, container, false ) || child.animated || child === ghostEl ) { 1090 return; 1091 } 1092 var childRect = getRect( child ); 1093 rect.left = Math.min( ( _rect$left = rect.left ) !== null && _rect$left !== void 0 ? _rect$left : Infinity, childRect.left ); 1094 rect.top = Math.min( ( _rect$top = rect.top ) !== null && _rect$top !== void 0 ? _rect$top : Infinity, childRect.top ); 1095 rect.right = Math.max( ( _rect$right = rect.right ) !== null && _rect$right !== void 0 ? _rect$right : -Infinity, childRect.right ); 1096 rect.bottom = Math.max( ( _rect$bottom = rect.bottom ) !== null && _rect$bottom !== void 0 ? _rect$bottom : -Infinity, childRect.bottom ); 1097 } ); 1098 rect.width = rect.right - rect.left; 1099 rect.height = rect.bottom - rect.top; 1100 rect.x = rect.left; 1101 rect.y = rect.top; 1102 return rect; 1103 } 1104 1105 function AnimationStateManager() { 1106 var animationStates = [], 1107 animationCallbackId; 1108 return { 1109 captureAnimationState: function captureAnimationState() { 1110 animationStates = []; 1111 if ( ! this.options.animation ) { 1112 return; 1113 } 1114 var children = [].slice.call( this.el.children );
vendor: 4,201 bytes, lines 1115-1231
1115 children.forEach( function( child ) { 1116 if ( css( child, 'display' ) === 'none' || child === Sortable.ghost ) { 1117 return; 1118 } 1119 animationStates.push( { 1120 target: child, 1121 rect: getRect( child ) 1122 } ); 1123 var fromRect = _objectSpread2( {}, animationStates[ animationStates.length - 1 ].rect ); 1124 1125 // If animating: compensate for current animation 1126 if ( child.thisAnimationDuration ) { 1127 var childMatrix = matrix( child, true ); 1128 if ( childMatrix ) { 1129 fromRect.top -= childMatrix.f; 1130 fromRect.left -= childMatrix.e; 1131 } 1132 } 1133 child.fromRect = fromRect; 1134 } ); 1135 }, 1136 addAnimationState: function addAnimationState( state ) { 1137 animationStates.push( state ); 1138 }, 1139 removeAnimationState: function removeAnimationState( target ) { 1140 animationStates.splice( indexOfObject( animationStates, { 1141 target: target 1142 } ), 1 ); 1143 }, 1144 animateAll: function animateAll( callback ) { 1145 var _this = this; 1146 if ( ! this.options.animation ) { 1147 clearTimeout( animationCallbackId ); 1148 if ( typeof callback === 'function' ) { 1149 callback(); 1150 } 1151 return; 1152 } 1153 var animating = false, 1154 animationTime = 0; 1155 animationStates.forEach( function( state ) { 1156 var time = 0, 1157 target = state.target, 1158 fromRect = target.fromRect, 1159 toRect = getRect( target ), 1160 prevFromRect = target.prevFromRect, 1161 prevToRect = target.prevToRect, 1162 animatingRect = state.rect, 1163 targetMatrix = matrix( target, true ); 1164 if ( targetMatrix ) { 1165 // Compensate for current animation 1166 toRect.top -= targetMatrix.f; 1167 toRect.left -= targetMatrix.e; 1168 } 1169 target.toRect = toRect; 1170 if ( target.thisAnimationDuration ) { 1171 // Could also check if animatingRect is between fromRect and toRect 1172 if ( isRectEqual( prevFromRect, toRect ) && ! isRectEqual( fromRect, toRect ) && 1173 // Make sure animatingRect is on line between toRect & fromRect 1174 ( animatingRect.top - toRect.top ) / ( animatingRect.left - toRect.left ) === ( fromRect.top - toRect.top ) / ( fromRect.left - toRect.left ) ) { 1175 // If returning to same place as started from animation and on same axis 1176 time = calculateRealTime( animatingRect, prevFromRect, prevToRect, _this.options ); 1177 } 1178 } 1179 1180 // if fromRect != toRect: animate 1181 if ( ! isRectEqual( toRect, fromRect ) ) { 1182 target.prevFromRect = fromRect; 1183 target.prevToRect = toRect; 1184 if ( ! time ) { 1185 time = _this.options.animation; 1186 } 1187 _this.animate( target, animatingRect, toRect, time ); 1188 } 1189 if ( time ) { 1190 animating = true; 1191 animationTime = Math.max( animationTime, time ); 1192 clearTimeout( target.animationResetTimer ); 1193 target.animationResetTimer = setTimeout( function() { 1194 target.animationTime = 0; 1195 target.prevFromRect = null; 1196 target.fromRect = null; 1197 target.prevToRect = null; 1198 target.thisAnimationDuration = null; 1199 }, time ); 1200 target.thisAnimationDuration = time; 1201 } 1202 } ); 1203 clearTimeout( animationCallbackId ); 1204 if ( ! animating ) { 1205 if ( typeof callback === 'function' ) { 1206 callback(); 1207 } 1208 } else { 1209 animationCallbackId = setTimeout( function() { 1210 if ( typeof callback === 'function' ) { 1211 callback(); 1212 } 1213 }, animationTime ); 1214 } 1215 animationStates = []; 1216 }, 1217 animate: function animate( target, currentRect, toRect, duration ) { 1218 if ( duration ) { 1219 css( target, 'transition', '' ); 1220 css( target, 'transform', '' ); 1221 var elMatrix = matrix( this.el ), 1222 scaleX = elMatrix && elMatrix.a, 1223 scaleY = elMatrix && elMatrix.d, 1224 translateX = ( currentRect.left - toRect.left ) / ( scaleX || 1 ), 1225 translateY = ( currentRect.top - toRect.top ) / ( scaleY || 1 ); 1226 target.animatingX = !! translateX; 1227 target.animatingY = !! translateY; 1228 css( target, 'transform', 'translate3d(' + translateX + 'px,' + translateY + 'px,0)' ); 1229 this.forRepaintDummy = repaint( target ); // repaint 1230 1231 css( target, 'transition', 'transform ' + duration + 'ms' + ( this.options.easing ? ' ' + this.options.easing : '' ) );
vendor: 15,223 bytes, lines 1232-1695
1232 css( target, 'transform', 'translate3d(0,0,0)' ); 1233 typeof target.animated === 'number' && clearTimeout( target.animated ); 1234 target.animated = setTimeout( function() { 1235 css( target, 'transition', '' ); 1236 css( target, 'transform', '' ); 1237 target.animated = false; 1238 target.animatingX = false; 1239 target.animatingY = false; 1240 }, duration ); 1241 } 1242 } 1243 }; 1244 } 1245 function repaint( target ) { 1246 return target.offsetWidth; 1247 } 1248 function calculateRealTime( animatingRect, fromRect, toRect, options ) { 1249 return Math.sqrt( Math.pow( fromRect.top - animatingRect.top, 2 ) + Math.pow( fromRect.left - animatingRect.left, 2 ) ) / Math.sqrt( Math.pow( fromRect.top - toRect.top, 2 ) + Math.pow( fromRect.left - toRect.left, 2 ) ) * options.animation; 1250 } 1251 1252 function dispatchEvent( _ref ) { 1253 var sortable = _ref.sortable, 1254 rootEl = _ref.rootEl, 1255 name = _ref.name, 1256 targetEl = _ref.targetEl, 1257 cloneEl = _ref.cloneEl, 1258 toEl = _ref.toEl, 1259 fromEl = _ref.fromEl, 1260 oldIndex = _ref.oldIndex, 1261 newIndex = _ref.newIndex, 1262 oldDraggableIndex = _ref.oldDraggableIndex, 1263 newDraggableIndex = _ref.newDraggableIndex, 1264 originalEvent = _ref.originalEvent, 1265 putSortable = _ref.putSortable, 1266 extraEventProperties = _ref.extraEventProperties; 1267 sortable = sortable || rootEl && rootEl[ expando ]; 1268 if ( ! sortable ) { 1269 return; 1270 } 1271 var evt, 1272 options = sortable.options, 1273 onName = 'on' + name.charAt( 0 ).toUpperCase() + name.substr( 1 ); 1274 // Support for new CustomEvent feature 1275 if ( window.CustomEvent && ! IE11OrLess && ! Edge ) { 1276 evt = new CustomEvent( name, { 1277 bubbles: true, 1278 cancelable: true 1279 } ); 1280 } else { 1281 evt = document.createEvent( 'Event' ); 1282 evt.initEvent( name, true, true ); 1283 } 1284 evt.to = toEl || rootEl; 1285 evt.from = fromEl || rootEl; 1286 evt.item = targetEl || rootEl; 1287 evt.clone = cloneEl; 1288 evt.oldIndex = oldIndex; 1289 evt.newIndex = newIndex; 1290 evt.oldDraggableIndex = oldDraggableIndex; 1291 evt.newDraggableIndex = newDraggableIndex; 1292 evt.originalEvent = originalEvent; 1293 evt.pullMode = putSortable ? putSortable.lastPutMode : undefined; 1294 var allEventProperties = _objectSpread2( _objectSpread2( {}, extraEventProperties ), PluginManager.getEventProperties( name, sortable ) ); 1295 for ( var option in allEventProperties ) { 1296 evt[ option ] = allEventProperties[ option ]; 1297 } 1298 if ( rootEl ) { 1299 rootEl.dispatchEvent( evt ); 1300 } 1301 if ( options[ onName ] ) { 1302 options[ onName ].call( sortable, evt ); 1303 } 1304 } 1305 1306 function _dispatchEvent( info ) { 1307 dispatchEvent( _objectSpread2( { 1308 putSortable: putSortable, 1309 cloneEl: cloneEl, 1310 targetEl: dragEl, 1311 rootEl: rootEl, 1312 oldIndex: oldIndex, 1313 oldDraggableIndex: oldDraggableIndex, 1314 newIndex: newIndex, 1315 newDraggableIndex: newDraggableIndex 1316 }, info ) ); 1317 } 1318 1319 // #1184 fix - Prevent click event on fallback if dragged but item not changed position 1320 if ( documentExists && ! ChromeForAndroid ) { 1321 document.addEventListener( 'click', function( evt ) { 1322 if ( ignoreNextClick ) { 1323 evt.preventDefault(); 1324 evt.stopPropagation && evt.stopPropagation(); 1325 evt.stopImmediatePropagation && evt.stopImmediatePropagation(); 1326 ignoreNextClick = false; 1327 return false; 1328 } 1329 }, true ); 1330 } 1331 1332 /** 1333 * @class Sortable 1334 * @param {HTMLElement} el 1335 * @param {Object} [options] 1336 */ 1337 function Sortable( el, options ) { 1338 var _defaults; 1339 var name; 1340 var fn; 1341 if ( ! ( el && el.nodeType && el.nodeType === 1 ) ) { 1342 throw 'Sortable: `el` must be an HTMLElement, not '.concat( {}.toString.call( el ) ); 1343 } 1344 this.el = el; // root element 1345 this.options = options = _extends( {}, options ); 1346 1347 // Export instance 1348 el[ expando ] = this; 1349 _defaults = { 1350 group: null, 1351 sort: true, 1352 disabled: false, 1353 store: null, 1354 handle: null, 1355 draggable: /^[uo]l$/i.test( el.nodeName ) ? '>li' : '>*', 1356 swapThreshold: 1, 1357 // percentage; 0 <= x <= 1 1358 invertSwap: false, 1359 // invert always 1360 invertedSwapThreshold: null, 1361 // will be set to same as swapThreshold if default 1362 removeCloneOnHide: true, 1363 direction: function direction() { 1364 return _detectDirection( el, this.options ); 1365 }, 1366 ghostClass: 'sortable-ghost', 1367 chosenClass: 'sortable-chosen', 1368 dragClass: 'sortable-drag', 1369 ignore: 'a, img', 1370 filter: null, 1371 preventOnFilter: true, 1372 animation: 0, 1373 easing: null, 1374 setData: function setData( dataTransfer, dragEl ) { 1375 dataTransfer.setData( 'Text', dragEl.textContent ); 1376 }, 1377 dropBubble: false, 1378 dragoverBubble: false, 1379 dataIdAttr: 'data-id', 1380 delay: 0, 1381 delayOnTouchOnly: false, 1382 touchStartThreshold: ( Number.parseInt ? Number : window ).parseInt( window.devicePixelRatio, 10 ) || 1, 1383 forceFallback: false, 1384 fallbackClass: 'sortable-fallback', 1385 fallbackOnBody: false, 1386 fallbackTolerance: 0, 1387 fallbackOffset: { 1388 x: 0, 1389 y: 0 1390 }, 1391 // Disabled on Safari: #1571; Enabled on Safari IOS: #2244 1392 supportPointer: Sortable.supportPointer !== false && 'PointerEvent' in window && ( ! Safari || IOS ), 1393 emptyInsertThreshold: 5 1394 }; 1395 PluginManager.initializePlugins( this, el, _defaults ); 1396 1397 // Set default options 1398 for ( name in _defaults ) { 1399 if ( ! ( name in options ) ) { 1400 options[ name ] = _defaults[ name ]; 1401 } 1402 } 1403 _prepareGroup( options ); 1404 1405 // Bind all private methods 1406 for ( fn in this ) { 1407 if ( fn.charAt( 0 ) === '_' && typeof this[ fn ] === 'function' ) { 1408 this[ fn ] = this[ fn ].bind( this ); 1409 } 1410 } 1411 1412 // Setup drag mode 1413 this.nativeDraggable = options.forceFallback ? false : supportDraggable; 1414 if ( this.nativeDraggable ) { 1415 // Touch start threshold cannot be greater than the native dragstart threshold 1416 this.options.touchStartThreshold = 1; 1417 } 1418 1419 // Bind events 1420 if ( options.supportPointer ) { 1421 on( el, 'pointerdown', this._onTapStart ); 1422 } else { 1423 on( el, 'mousedown', this._onTapStart ); 1424 on( el, 'touchstart', this._onTapStart ); 1425 } 1426 if ( this.nativeDraggable ) { 1427 on( el, 'dragover', this ); 1428 on( el, 'dragenter', this ); 1429 } 1430 sortables.push( this.el ); 1431 1432 // Restore sorting 1433 if ( options.store && options.store.get ) { 1434 this.sort( options.store.get( this ) || [] ); 1435 } 1436 1437 // Add animation state manager 1438 _extends( this, AnimationStateManager() ); 1439 } 1440 Sortable.prototype = /** @lends Sortable.prototype */{ 1441 constructor: Sortable, 1442 _isOutsideThisEl: function _isOutsideThisEl( target ) { 1443 if ( ! this.el.contains( target ) && target !== this.el ) { 1444 lastTarget = null; 1445 } 1446 }, 1447 _getDirection: function _getDirection( evt, target ) { 1448 return typeof this.options.direction === 'function' ? this.options.direction.call( this, evt, target, dragEl ) : this.options.direction; 1449 }, 1450 _onTapStart: function _onTapStart( /** Event|TouchEvent */evt ) { 1451 if ( ! evt.cancelable ) { 1452 return; 1453 } 1454 var _this = this, 1455 el = this.el, 1456 options = this.options, 1457 preventOnFilter = options.preventOnFilter, 1458 type = evt.type, 1459 touch = evt.touches && evt.touches[ 0 ] || evt.pointerType && evt.pointerType === 'touch' && evt, 1460 target = ( touch || evt ).target, 1461 originalTarget = evt.target.shadowRoot && ( evt.path && evt.path[ 0 ] || evt.composedPath && evt.composedPath()[ 0 ] ) || target, 1462 filter = options.filter; 1463 _saveInputCheckedState( el ); 1464 1465 // Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group. 1466 if ( dragEl ) { 1467 return; 1468 } 1469 if ( /mousedown|pointerdown/.test( type ) && evt.button !== 0 || options.disabled ) { 1470 return; // only left button and enabled 1471 } 1472 1473 // cancel dnd if original target is content editable 1474 if ( originalTarget.isContentEditable ) { 1475 return; 1476 } 1477 1478 // Safari ignores further event handling after mousedown 1479 if ( ! this.nativeDraggable && Safari && target && target.tagName.toUpperCase() === 'SELECT' ) { 1480 return; 1481 } 1482 target = closest( target, options.draggable, el, false ); 1483 if ( target && target.animated ) { 1484 return; 1485 } 1486 if ( lastDownEl === target ) { 1487 // Ignoring duplicate `down` 1488 return; 1489 } 1490 1491 // Get the index of the dragged element within its parent 1492 oldIndex = index( target ); 1493 oldDraggableIndex = index( target, options.draggable ); 1494 1495 // Check filter 1496 if ( typeof filter === 'function' ) { 1497 if ( filter.call( this, evt, target, this ) ) { 1498 _dispatchEvent( { 1499 sortable: _this, 1500 rootEl: originalTarget, 1501 name: 'filter', 1502 targetEl: target, 1503 toEl: el, 1504 fromEl: el 1505 } ); 1506 pluginEvent( 'filter', _this, { 1507 evt: evt 1508 } ); 1509 preventOnFilter && evt.preventDefault(); 1510 return; // cancel dnd 1511 } 1512 } else if ( filter ) { 1513 filter = filter.split( ',' ).some( function( criteria ) { 1514 criteria = closest( originalTarget, criteria.trim(), el, false ); 1515 if ( criteria ) { 1516 _dispatchEvent( { 1517 sortable: _this, 1518 rootEl: criteria, 1519 name: 'filter', 1520 targetEl: target, 1521 fromEl: el, 1522 toEl: el 1523 } ); 1524 pluginEvent( 'filter', _this, { 1525 evt: evt 1526 } ); 1527 return true; 1528 } 1529 } ); 1530 if ( filter ) { 1531 preventOnFilter && evt.preventDefault(); 1532 return; // cancel dnd 1533 } 1534 } 1535 if ( options.handle && ! closest( originalTarget, options.handle, el, false ) ) { 1536 return; 1537 } 1538 1539 // Prepare `dragstart` 1540 this._prepareDragStart( evt, touch, target ); 1541 }, 1542 _prepareDragStart: function _prepareDragStart( /** Event */evt, /** Touch */touch, /** HTMLElement */target ) { 1543 var _this = this, 1544 el = _this.el, 1545 options = _this.options, 1546 ownerDocument = el.ownerDocument, 1547 dragStartFn; 1548 if ( target && ! dragEl && target.parentNode === el ) { 1549 var dragRect = getRect( target ); 1550 rootEl = el; 1551 dragEl = target; 1552 parentEl = dragEl.parentNode; 1553 nextEl = dragEl.nextSibling; 1554 lastDownEl = target; 1555 activeGroup = options.group; 1556 Sortable.dragged = dragEl; 1557 tapEvt = { 1558 target: dragEl, 1559 clientX: ( touch || evt ).clientX, 1560 clientY: ( touch || evt ).clientY 1561 }; 1562 tapDistanceLeft = tapEvt.clientX - dragRect.left; 1563 tapDistanceTop = tapEvt.clientY - dragRect.top; 1564 this._lastX = ( touch || evt ).clientX; 1565 this._lastY = ( touch || evt ).clientY; 1566 dragEl.style[ 'will-change' ] = 'all'; 1567 dragStartFn = function dragStartFn() { 1568 pluginEvent( 'delayEnded', _this, { 1569 evt: evt 1570 } ); 1571 if ( Sortable.eventCanceled ) { 1572 _this._onDrop(); 1573 return; 1574 } 1575 // Delayed drag has been triggered 1576 // we can re-enable the events: touchmove/mousemove 1577 _this._disableDelayedDragEvents(); 1578 if ( ! FireFox && _this.nativeDraggable ) { 1579 dragEl.draggable = true; 1580 } 1581 1582 // Bind the events: dragstart/dragend 1583 _this._triggerDragStart( evt, touch ); 1584 1585 // Drag start event 1586 _dispatchEvent( { 1587 sortable: _this, 1588 name: 'choose', 1589 originalEvent: evt 1590 } ); 1591 1592 // Chosen item 1593 toggleClass( dragEl, options.chosenClass, true ); 1594 }; 1595 1596 // Disable "draggable" 1597 options.ignore.split( ',' ).forEach( function( criteria ) { 1598 find( dragEl, criteria.trim(), _disableDraggable ); 1599 } ); 1600 on( ownerDocument, 'dragover', nearestEmptyInsertDetectEvent ); 1601 on( ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent ); 1602 on( ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent ); 1603 if ( options.supportPointer ) { 1604 on( ownerDocument, 'pointerup', _this._onDrop ); 1605 // Native D&D triggers pointercancel 1606 ! this.nativeDraggable && on( ownerDocument, 'pointercancel', _this._onDrop ); 1607 } else { 1608 on( ownerDocument, 'mouseup', _this._onDrop ); 1609 on( ownerDocument, 'touchend', _this._onDrop ); 1610 on( ownerDocument, 'touchcancel', _this._onDrop ); 1611 } 1612 1613 // Make dragEl draggable (must be before delay for FireFox) 1614 if ( FireFox && this.nativeDraggable ) { 1615 this.options.touchStartThreshold = 4; 1616 dragEl.draggable = true; 1617 } 1618 pluginEvent( 'delayStart', this, { 1619 evt: evt 1620 } ); 1621 1622 // Delay is impossible for native DnD in Edge or IE 1623 if ( options.delay && ( ! options.delayOnTouchOnly || touch ) && ( ! this.nativeDraggable || ! ( Edge || IE11OrLess ) ) ) { 1624 if ( Sortable.eventCanceled ) { 1625 this._onDrop(); 1626 return; 1627 } 1628 // If the user moves the pointer or let go the click or touch 1629 // before the delay has been reached: 1630 // disable the delayed drag 1631 if ( options.supportPointer ) { 1632 on( ownerDocument, 'pointerup', _this._disableDelayedDrag ); 1633 on( ownerDocument, 'pointercancel', _this._disableDelayedDrag ); 1634 } else { 1635 on( ownerDocument, 'mouseup', _this._disableDelayedDrag ); 1636 on( ownerDocument, 'touchend', _this._disableDelayedDrag ); 1637 on( ownerDocument, 'touchcancel', _this._disableDelayedDrag ); 1638 } 1639 on( ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler ); 1640 on( ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler ); 1641 options.supportPointer && on( ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler ); 1642 _this._dragStartTimer = setTimeout( dragStartFn, options.delay ); 1643 } else { 1644 dragStartFn(); 1645 } 1646 } 1647 }, 1648 _delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler( /** TouchEvent|PointerEvent */e ) { 1649 var touch = e.touches ? e.touches[ 0 ] : e; 1650 if ( Math.max( Math.abs( touch.clientX - this._lastX ), Math.abs( touch.clientY - this._lastY ) ) >= Math.floor( this.options.touchStartThreshold / ( this.nativeDraggable && window.devicePixelRatio || 1 ) ) ) { 1651 this._disableDelayedDrag(); 1652 } 1653 }, 1654 _disableDelayedDrag: function _disableDelayedDrag() { 1655 dragEl && _disableDraggable( dragEl ); 1656 clearTimeout( this._dragStartTimer ); 1657 this._disableDelayedDragEvents(); 1658 }, 1659 _disableDelayedDragEvents: function _disableDelayedDragEvents() { 1660 var ownerDocument = this.el.ownerDocument; 1661 off( ownerDocument, 'mouseup', this._disableDelayedDrag ); 1662 off( ownerDocument, 'touchend', this._disableDelayedDrag ); 1663 off( ownerDocument, 'touchcancel', this._disableDelayedDrag ); 1664 off( ownerDocument, 'pointerup', this._disableDelayedDrag ); 1665 off( ownerDocument, 'pointercancel', this._disableDelayedDrag ); 1666 off( ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler ); 1667 off( ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler ); 1668 off( ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler ); 1669 }, 1670 _triggerDragStart: function _triggerDragStart( /** Event */evt, /** Touch */touch ) { 1671 touch = touch || evt.pointerType == 'touch' && evt; 1672 if ( ! this.nativeDraggable || touch ) { 1673 if ( this.options.supportPointer ) { 1674 on( document, 'pointermove', this._onTouchMove ); 1675 } else if ( touch ) { 1676 on( document, 'touchmove', this._onTouchMove ); 1677 } else { 1678 on( document, 'mousemove', this._onTouchMove ); 1679 } 1680 } else { 1681 on( dragEl, 'dragend', this ); 1682 on( rootEl, 'dragstart', this._onDragStart ); 1683 } 1684 try { 1685 if ( document.selection ) { 1686 _nextTick( function() { 1687 document.selection.empty(); 1688 } ); 1689 } else { 1690 window.getSelection().removeAllRanges(); 1691 } 1692 } catch ( err ) {} 1693 }, 1694 _dragStarted: function _dragStarted( fallback, evt ) { 1695 awaitingDragStarted = false;
vendor: 5,416 bytes, lines 1696-1839
1696 if ( rootEl && dragEl ) { 1697 pluginEvent( 'dragStarted', this, { 1698 evt: evt 1699 } ); 1700 if ( this.nativeDraggable ) { 1701 on( document, 'dragover', _checkOutsideTargetEl ); 1702 } 1703 var options = this.options; 1704 1705 // Apply effect 1706 ! fallback && toggleClass( dragEl, options.dragClass, false ); 1707 toggleClass( dragEl, options.ghostClass, true ); 1708 Sortable.active = this; 1709 fallback && this._appendGhost(); 1710 1711 // Drag start event 1712 _dispatchEvent( { 1713 sortable: this, 1714 name: 'start', 1715 originalEvent: evt 1716 } ); 1717 } else { 1718 this._nulling(); 1719 } 1720 }, 1721 _emulateDragOver: function _emulateDragOver() { 1722 if ( touchEvt ) { 1723 this._lastX = touchEvt.clientX; 1724 this._lastY = touchEvt.clientY; 1725 _hideGhostForTarget(); 1726 var target = document.elementFromPoint( touchEvt.clientX, touchEvt.clientY ); 1727 var parent = target; 1728 while ( target && target.shadowRoot ) { 1729 target = target.shadowRoot.elementFromPoint( touchEvt.clientX, touchEvt.clientY ); 1730 if ( target === parent ) { 1731 break; 1732 } 1733 parent = target; 1734 } 1735 dragEl.parentNode[ expando ]._isOutsideThisEl( target ); 1736 if ( parent ) { 1737 do { 1738 if ( parent[ expando ] ) { 1739 var inserted = void 0; 1740 inserted = parent[ expando ]._onDragOver( { 1741 clientX: touchEvt.clientX, 1742 clientY: touchEvt.clientY, 1743 target: target, 1744 rootEl: parent 1745 } ); 1746 if ( inserted && ! this.options.dragoverBubble ) { 1747 break; 1748 } 1749 } 1750 target = parent; // store last element 1751 } 1752 while ( ( parent = getParentOrHost( parent ) ) ); 1753 } 1754 _unhideGhostForTarget(); 1755 } 1756 }, 1757 _onTouchMove: function _onTouchMove( /**TouchEvent*/evt ) { 1758 if ( tapEvt ) { 1759 var options = this.options, 1760 fallbackTolerance = options.fallbackTolerance, 1761 fallbackOffset = options.fallbackOffset, 1762 touch = evt.touches ? evt.touches[ 0 ] : evt, 1763 ghostMatrix = ghostEl && matrix( ghostEl, true ), 1764 scaleX = ghostEl && ghostMatrix && ghostMatrix.a, 1765 scaleY = ghostEl && ghostMatrix && ghostMatrix.d, 1766 relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset( ghostRelativeParent ), 1767 dx = ( touch.clientX - tapEvt.clientX + fallbackOffset.x ) / ( scaleX || 1 ) + ( relativeScrollOffset ? relativeScrollOffset[ 0 ] - ghostRelativeParentInitialScroll[ 0 ] : 0 ) / ( scaleX || 1 ), 1768 dy = ( touch.clientY - tapEvt.clientY + fallbackOffset.y ) / ( scaleY || 1 ) + ( relativeScrollOffset ? relativeScrollOffset[ 1 ] - ghostRelativeParentInitialScroll[ 1 ] : 0 ) / ( scaleY || 1 ); 1769 1770 // only set the status to dragging, when we are actually dragging 1771 if ( ! Sortable.active && ! awaitingDragStarted ) { 1772 if ( fallbackTolerance && Math.max( Math.abs( touch.clientX - this._lastX ), Math.abs( touch.clientY - this._lastY ) ) < fallbackTolerance ) { 1773 return; 1774 } 1775 this._onDragStart( evt, true ); 1776 } 1777 if ( ghostEl ) { 1778 if ( ghostMatrix ) { 1779 ghostMatrix.e += dx - ( lastDx || 0 ); 1780 ghostMatrix.f += dy - ( lastDy || 0 ); 1781 } else { 1782 ghostMatrix = { 1783 a: 1, 1784 b: 0, 1785 c: 0, 1786 d: 1, 1787 e: dx, 1788 f: dy 1789 }; 1790 } 1791 var cssMatrix = 'matrix('.concat( ghostMatrix.a, ',' ).concat( ghostMatrix.b, ',' ).concat( ghostMatrix.c, ',' ).concat( ghostMatrix.d, ',' ).concat( ghostMatrix.e, ',' ).concat( ghostMatrix.f, ')' ); 1792 css( ghostEl, 'webkitTransform', cssMatrix ); 1793 css( ghostEl, 'mozTransform', cssMatrix ); 1794 css( ghostEl, 'msTransform', cssMatrix ); 1795 css( ghostEl, 'transform', cssMatrix ); 1796 lastDx = dx; 1797 lastDy = dy; 1798 touchEvt = touch; 1799 } 1800 evt.cancelable && evt.preventDefault(); 1801 } 1802 }, 1803 _appendGhost: function _appendGhost() { 1804 // Bug if using scale(): https://stackoverflow.com/questions/2637058 1805 // Not being adjusted for 1806 if ( ! ghostEl ) { 1807 var container = this.options.fallbackOnBody ? document.body : rootEl, 1808 rect = getRect( dragEl, true, PositionGhostAbsolutely, true, container ), 1809 options = this.options; 1810 1811 // Position absolutely 1812 if ( PositionGhostAbsolutely ) { 1813 // Get relatively positioned parent 1814 ghostRelativeParent = container; 1815 while ( css( ghostRelativeParent, 'position' ) === 'static' && css( ghostRelativeParent, 'transform' ) === 'none' && ghostRelativeParent !== document ) { 1816 ghostRelativeParent = ghostRelativeParent.parentNode; 1817 } 1818 if ( ghostRelativeParent !== document.body && ghostRelativeParent !== document.documentElement ) { 1819 if ( ghostRelativeParent === document ) { 1820 ghostRelativeParent = getWindowScrollingElement(); 1821 } 1822 rect.top += ghostRelativeParent.scrollTop; 1823 rect.left += ghostRelativeParent.scrollLeft; 1824 } else { 1825 ghostRelativeParent = getWindowScrollingElement(); 1826 } 1827 ghostRelativeParentInitialScroll = getRelativeScrollOffset( ghostRelativeParent ); 1828 } 1829 ghostEl = dragEl.cloneNode( true ); 1830 toggleClass( ghostEl, options.ghostClass, false ); 1831 toggleClass( ghostEl, options.fallbackClass, true ); 1832 toggleClass( ghostEl, options.dragClass, true ); 1833 css( ghostEl, 'transition', '' ); 1834 css( ghostEl, 'transform', '' ); 1835 css( ghostEl, 'box-sizing', 'border-box' ); 1836 css( ghostEl, 'margin', 0 ); 1837 css( ghostEl, 'top', rect.top ); 1838 css( ghostEl, 'left', rect.left ); 1839 css( ghostEl, 'width', rect.width );
vendor: 4,303 bytes, lines 1840-1977
1840 css( ghostEl, 'height', rect.height ); 1841 css( ghostEl, 'opacity', '0.8' ); 1842 css( ghostEl, 'position', PositionGhostAbsolutely ? 'absolute' : 'fixed' ); 1843 css( ghostEl, 'zIndex', '100000' ); 1844 css( ghostEl, 'pointerEvents', 'none' ); 1845 Sortable.ghost = ghostEl; 1846 container.appendChild( ghostEl ); 1847 1848 // Set transform-origin 1849 css( ghostEl, 'transform-origin', ( tapDistanceLeft / parseInt( ghostEl.style.width, 10 ) * 100 ) + '% ' + ( tapDistanceTop / parseInt( ghostEl.style.height, 10 ) * 100 ) + '%' ); 1850 } 1851 }, 1852 _onDragStart: function _onDragStart( /**Event*/evt, /**boolean*/fallback ) { 1853 var _this = this; 1854 var dataTransfer = evt.dataTransfer; 1855 var options = _this.options; 1856 pluginEvent( 'dragStart', this, { 1857 evt: evt 1858 } ); 1859 if ( Sortable.eventCanceled ) { 1860 this._onDrop(); 1861 return; 1862 } 1863 pluginEvent( 'setupClone', this ); 1864 if ( ! Sortable.eventCanceled ) { 1865 cloneEl = clone( dragEl ); 1866 cloneEl.removeAttribute( 'id' ); 1867 cloneEl.draggable = false; 1868 cloneEl.style[ 'will-change' ] = ''; 1869 this._hideClone(); 1870 toggleClass( cloneEl, this.options.chosenClass, false ); 1871 Sortable.clone = cloneEl; 1872 } 1873 1874 // #1143: IFrame support workaround 1875 _this.cloneId = _nextTick( function() { 1876 pluginEvent( 'clone', _this ); 1877 if ( Sortable.eventCanceled ) { 1878 return; 1879 } 1880 if ( ! _this.options.removeCloneOnHide ) { 1881 rootEl.insertBefore( cloneEl, dragEl ); 1882 } 1883 _this._hideClone(); 1884 _dispatchEvent( { 1885 sortable: _this, 1886 name: 'clone' 1887 } ); 1888 } ); 1889 ! fallback && toggleClass( dragEl, options.dragClass, true ); 1890 1891 // Set proper drop events 1892 if ( fallback ) { 1893 ignoreNextClick = true; 1894 _this._loopId = setInterval( _this._emulateDragOver, 50 ); 1895 } else { 1896 // Undo what was set in _prepareDragStart before drag started 1897 off( document, 'mouseup', _this._onDrop ); 1898 off( document, 'touchend', _this._onDrop ); 1899 off( document, 'touchcancel', _this._onDrop ); 1900 if ( dataTransfer ) { 1901 dataTransfer.effectAllowed = 'move'; 1902 options.setData && options.setData.call( _this, dataTransfer, dragEl ); 1903 } 1904 on( document, 'drop', _this ); 1905 1906 // #1276 fix: 1907 css( dragEl, 'transform', 'translateZ(0)' ); 1908 } 1909 awaitingDragStarted = true; 1910 _this._dragStartId = _nextTick( _this._dragStarted.bind( _this, fallback, evt ) ); 1911 on( document, 'selectstart', _this ); 1912 moved = true; 1913 window.getSelection().removeAllRanges(); 1914 if ( Safari ) { 1915 css( document.body, 'user-select', 'none' ); 1916 } 1917 }, 1918 // Returns true - if no further action is needed (either inserted or another condition) 1919 _onDragOver: function _onDragOver( /**Event*/evt ) { 1920 var el = this.el, 1921 target = evt.target, 1922 dragRect, 1923 targetRect, 1924 revert, 1925 options = this.options, 1926 group = options.group, 1927 activeSortable = Sortable.active, 1928 isOwner = activeGroup === group, 1929 canSort = options.sort, 1930 fromSortable = putSortable || activeSortable, 1931 vertical, 1932 _this = this, 1933 completedFired = false; 1934 if ( _silent ) { 1935 return; 1936 } 1937 function dragOverEvent( name, extra ) { 1938 pluginEvent( name, _this, _objectSpread2( { 1939 evt: evt, 1940 isOwner: isOwner, 1941 axis: vertical ? 'vertical' : 'horizontal', 1942 revert: revert, 1943 dragRect: dragRect, 1944 targetRect: targetRect, 1945 canSort: canSort, 1946 fromSortable: fromSortable, 1947 target: target, 1948 completed: completed, 1949 onMove: function onMove( target, after ) { 1950 return _onMove( rootEl, el, dragEl, dragRect, target, getRect( target ), evt, after ); 1951 }, 1952 changed: changed 1953 }, extra ) ); 1954 } 1955 1956 // Capture animation state 1957 function capture() { 1958 dragOverEvent( 'dragOverAnimationCapture' ); 1959 _this.captureAnimationState(); 1960 if ( _this !== fromSortable ) { 1961 fromSortable.captureAnimationState(); 1962 } 1963 } 1964 1965 // Return invocation when dragEl is inserted (or completed) 1966 function completed( insertion ) { 1967 dragOverEvent( 'dragOverCompleted', { 1968 insertion: insertion 1969 } ); 1970 if ( insertion ) { 1971 // Clones must be hidden before folding animation to capture dragRectAbsolute properly 1972 if ( isOwner ) { 1973 activeSortable._hideClone(); 1974 } else { 1975 activeSortable._showClone( _this ); 1976 } 1977 if ( _this !== fromSortable ) {
vendor: 5,070 bytes, lines 1978-2117
1978 // Set ghost class to new sortable's ghost class 1979 toggleClass( dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false ); 1980 toggleClass( dragEl, options.ghostClass, true ); 1981 } 1982 if ( putSortable !== _this && _this !== Sortable.active ) { 1983 putSortable = _this; 1984 } else if ( _this === Sortable.active && putSortable ) { 1985 putSortable = null; 1986 } 1987 1988 // Animation 1989 if ( fromSortable === _this ) { 1990 _this._ignoreWhileAnimating = target; 1991 } 1992 _this.animateAll( function() { 1993 dragOverEvent( 'dragOverAnimationComplete' ); 1994 _this._ignoreWhileAnimating = null; 1995 } ); 1996 if ( _this !== fromSortable ) { 1997 fromSortable.animateAll(); 1998 fromSortable._ignoreWhileAnimating = null; 1999 } 2000 } 2001 2002 // Null lastTarget if it is not inside a previously swapped element 2003 if ( target === dragEl && ! dragEl.animated || target === el && ! target.animated ) { 2004 lastTarget = null; 2005 } 2006 2007 // no bubbling and not fallback 2008 if ( ! options.dragoverBubble && ! evt.rootEl && target !== document ) { 2009 dragEl.parentNode[ expando ]._isOutsideThisEl( evt.target ); 2010 2011 // Do not detect for empty insert if already inserted 2012 ! insertion && nearestEmptyInsertDetectEvent( evt ); 2013 } 2014 ! options.dragoverBubble && evt.stopPropagation && evt.stopPropagation(); 2015 return completedFired = true; 2016 } 2017 2018 // Call when dragEl has been inserted 2019 function changed() { 2020 newIndex = index( dragEl ); 2021 newDraggableIndex = index( dragEl, options.draggable ); 2022 _dispatchEvent( { 2023 sortable: _this, 2024 name: 'change', 2025 toEl: el, 2026 newIndex: newIndex, 2027 newDraggableIndex: newDraggableIndex, 2028 originalEvent: evt 2029 } ); 2030 } 2031 if ( evt.preventDefault !== void 0 ) { 2032 evt.cancelable && evt.preventDefault(); 2033 } 2034 target = closest( target, options.draggable, el, true ); 2035 dragOverEvent( 'dragOver' ); 2036 if ( Sortable.eventCanceled ) { 2037 return completedFired; 2038 } 2039 if ( dragEl.contains( evt.target ) || target.animated && target.animatingX && target.animatingY || _this._ignoreWhileAnimating === target ) { 2040 return completed( false ); 2041 } 2042 ignoreNextClick = false; 2043 if ( activeSortable && ! options.disabled && ( isOwner ? canSort || ( revert = parentEl !== rootEl ) // Reverting item into the original list 2044 : putSortable === this || ( this.lastPutMode = activeGroup.checkPull( this, activeSortable, dragEl, evt ) ) && group.checkPut( this, activeSortable, dragEl, evt ) ) ) { 2045 vertical = this._getDirection( evt, target ) === 'vertical'; 2046 dragRect = getRect( dragEl ); 2047 dragOverEvent( 'dragOverValid' ); 2048 if ( Sortable.eventCanceled ) { 2049 return completedFired; 2050 } 2051 if ( revert ) { 2052 parentEl = rootEl; // actualization 2053 capture(); 2054 this._hideClone(); 2055 dragOverEvent( 'revert' ); 2056 if ( ! Sortable.eventCanceled ) { 2057 if ( nextEl ) { 2058 rootEl.insertBefore( dragEl, nextEl ); 2059 } else { 2060 rootEl.appendChild( dragEl ); 2061 } 2062 } 2063 return completed( true ); 2064 } 2065 var elLastChild = lastChild( el, options.draggable ); 2066 if ( ! elLastChild || _ghostIsLast( evt, vertical, this ) && ! elLastChild.animated ) { 2067 // Insert to end of list 2068 2069 // If already at end of list: Do not insert 2070 if ( elLastChild === dragEl ) { 2071 return completed( false ); 2072 } 2073 2074 // if there is a last element, it is the target 2075 if ( elLastChild && el === evt.target ) { 2076 target = elLastChild; 2077 } 2078 if ( target ) { 2079 targetRect = getRect( target ); 2080 } 2081 if ( _onMove( rootEl, el, dragEl, dragRect, target, targetRect, evt, !! target ) !== false ) { 2082 capture(); 2083 if ( elLastChild && elLastChild.nextSibling ) { 2084 // the last draggable element is not the last node 2085 el.insertBefore( dragEl, elLastChild.nextSibling ); 2086 } else { 2087 el.appendChild( dragEl ); 2088 } 2089 parentEl = el; // actualization 2090 2091 changed(); 2092 return completed( true ); 2093 } 2094 } else if ( elLastChild && _ghostIsFirst( evt, vertical, this ) ) { 2095 // Insert to start of list 2096 var firstChild = getChild( el, 0, options, true ); 2097 if ( firstChild === dragEl ) { 2098 return completed( false ); 2099 } 2100 target = firstChild; 2101 targetRect = getRect( target ); 2102 if ( _onMove( rootEl, el, dragEl, dragRect, target, targetRect, evt, false ) !== false ) { 2103 capture(); 2104 el.insertBefore( dragEl, firstChild ); 2105 parentEl = el; // actualization 2106 2107 changed(); 2108 return completed( true ); 2109 } 2110 } else if ( target.parentNode === el ) { 2111 targetRect = getRect( target ); 2112 var direction = 0, 2113 targetBeforeFirstSwap, 2114 differentLevel = dragEl.parentNode !== el, 2115 differentRowCol = ! _dragElInRowColumn( dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical ), 2116 side1 = vertical ? 'top' : 'left', 2117 scrolledPastTop = isScrolledPast( target, 'top', 'top' ) || isScrolledPast( dragEl, 'top', 'top' ),
vendor: 1,709 bytes, lines 2118-2156
2118 scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0; 2119 if ( lastTarget !== target ) { 2120 targetBeforeFirstSwap = targetRect[ side1 ]; 2121 pastFirstInvertThresh = false; 2122 isCircumstantialInvert = ! differentRowCol && options.invertSwap || differentLevel; 2123 } 2124 direction = _getSwapDirection( evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target ); 2125 var sibling; 2126 if ( direction !== 0 ) { 2127 // Check if target is beside dragEl in respective direction (ignoring hidden elements) 2128 var dragIndex = index( dragEl ); 2129 do { 2130 dragIndex -= direction; 2131 sibling = parentEl.children[ dragIndex ]; 2132 } while ( sibling && ( css( sibling, 'display' ) === 'none' || sibling === ghostEl ) ); 2133 } 2134 // If dragEl is already beside target: Do not insert 2135 if ( direction === 0 || sibling === target ) { 2136 return completed( false ); 2137 } 2138 lastTarget = target; 2139 lastDirection = direction; 2140 var nextSibling = target.nextElementSibling, 2141 after = false; 2142 after = direction === 1; 2143 var moveVector = _onMove( rootEl, el, dragEl, dragRect, target, targetRect, evt, after ); 2144 if ( moveVector !== false ) { 2145 if ( moveVector === 1 || moveVector === -1 ) { 2146 after = moveVector === 1; 2147 } 2148 _silent = true; 2149 setTimeout( _unsilent, 30 ); 2150 capture(); 2151 if ( after && ! nextSibling ) { 2152 el.appendChild( dragEl ); 2153 } else { 2154 target.parentNode.insertBefore( dragEl, after ? nextSibling : target ); 2155 } 2156
vendor: 5,178 bytes, lines 2157-2334
2157 // Undo chrome's scroll adjustment (has no effect on other browsers) 2158 if ( scrolledPastTop ) { 2159 scrollBy( scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop ); 2160 } 2161 parentEl = dragEl.parentNode; // actualization 2162 2163 // must be done before animation 2164 if ( targetBeforeFirstSwap !== undefined && ! isCircumstantialInvert ) { 2165 targetMoveDistance = Math.abs( targetBeforeFirstSwap - getRect( target )[ side1 ] ); 2166 } 2167 changed(); 2168 return completed( true ); 2169 } 2170 } 2171 if ( el.contains( dragEl ) ) { 2172 return completed( false ); 2173 } 2174 } 2175 return false; 2176 }, 2177 _ignoreWhileAnimating: null, 2178 _offMoveEvents: function _offMoveEvents() { 2179 off( document, 'mousemove', this._onTouchMove ); 2180 off( document, 'touchmove', this._onTouchMove ); 2181 off( document, 'pointermove', this._onTouchMove ); 2182 off( document, 'dragover', nearestEmptyInsertDetectEvent ); 2183 off( document, 'mousemove', nearestEmptyInsertDetectEvent ); 2184 off( document, 'touchmove', nearestEmptyInsertDetectEvent ); 2185 }, 2186 _offUpEvents: function _offUpEvents() { 2187 var ownerDocument = this.el.ownerDocument; 2188 off( ownerDocument, 'mouseup', this._onDrop ); 2189 off( ownerDocument, 'touchend', this._onDrop ); 2190 off( ownerDocument, 'pointerup', this._onDrop ); 2191 off( ownerDocument, 'pointercancel', this._onDrop ); 2192 off( ownerDocument, 'touchcancel', this._onDrop ); 2193 off( document, 'selectstart', this ); 2194 }, 2195 _onDrop: function _onDrop( /**Event*/evt ) { 2196 var el = this.el, 2197 options = this.options; 2198 2199 // Get the index of the dragged element within its parent 2200 newIndex = index( dragEl ); 2201 newDraggableIndex = index( dragEl, options.draggable ); 2202 pluginEvent( 'drop', this, { 2203 evt: evt 2204 } ); 2205 parentEl = dragEl && dragEl.parentNode; 2206 2207 // Get again after plugin event 2208 newIndex = index( dragEl ); 2209 newDraggableIndex = index( dragEl, options.draggable ); 2210 if ( Sortable.eventCanceled ) { 2211 this._nulling(); 2212 return; 2213 } 2214 awaitingDragStarted = false; 2215 isCircumstantialInvert = false; 2216 pastFirstInvertThresh = false; 2217 clearInterval( this._loopId ); 2218 clearTimeout( this._dragStartTimer ); 2219 _cancelNextTick( this.cloneId ); 2220 _cancelNextTick( this._dragStartId ); 2221 2222 // Unbind events 2223 if ( this.nativeDraggable ) { 2224 off( document, 'drop', this ); 2225 off( el, 'dragstart', this._onDragStart ); 2226 } 2227 this._offMoveEvents(); 2228 this._offUpEvents(); 2229 if ( Safari ) { 2230 css( document.body, 'user-select', '' ); 2231 } 2232 css( dragEl, 'transform', '' ); 2233 if ( evt ) { 2234 if ( moved ) { 2235 evt.cancelable && evt.preventDefault(); 2236 ! options.dropBubble && evt.stopPropagation(); 2237 } 2238 ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild( ghostEl ); 2239 if ( rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone' ) { 2240 // Remove clone(s) 2241 cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild( cloneEl ); 2242 } 2243 if ( dragEl ) { 2244 if ( this.nativeDraggable ) { 2245 off( dragEl, 'dragend', this ); 2246 } 2247 _disableDraggable( dragEl ); 2248 dragEl.style[ 'will-change' ] = ''; 2249 2250 // Remove classes 2251 // ghostClass is added in dragStarted 2252 if ( moved && ! awaitingDragStarted ) { 2253 toggleClass( dragEl, putSortable ? putSortable.options.ghostClass : this.options.ghostClass, false ); 2254 } 2255 toggleClass( dragEl, this.options.chosenClass, false ); 2256 2257 // Drag stop event 2258 _dispatchEvent( { 2259 sortable: this, 2260 name: 'unchoose', 2261 toEl: parentEl, 2262 newIndex: null, 2263 newDraggableIndex: null, 2264 originalEvent: evt 2265 } ); 2266 if ( rootEl !== parentEl ) { 2267 if ( newIndex >= 0 ) { 2268 // Add event 2269 _dispatchEvent( { 2270 rootEl: parentEl, 2271 name: 'add', 2272 toEl: parentEl, 2273 fromEl: rootEl, 2274 originalEvent: evt 2275 } ); 2276 2277 // Remove event 2278 _dispatchEvent( { 2279 sortable: this, 2280 name: 'remove', 2281 toEl: parentEl, 2282 originalEvent: evt 2283 } ); 2284 2285 // drag from one list and drop into another 2286 _dispatchEvent( { 2287 rootEl: parentEl, 2288 name: 'sort', 2289 toEl: parentEl, 2290 fromEl: rootEl, 2291 originalEvent: evt 2292 } ); 2293 _dispatchEvent( { 2294 sortable: this, 2295 name: 'sort', 2296 toEl: parentEl, 2297 originalEvent: evt 2298 } ); 2299 } 2300 putSortable && putSortable.save(); 2301 } else if ( newIndex !== oldIndex ) { 2302 if ( newIndex >= 0 ) { 2303 // drag & drop within the same list 2304 _dispatchEvent( { 2305 sortable: this, 2306 name: 'update', 2307 toEl: parentEl, 2308 originalEvent: evt 2309 } ); 2310 _dispatchEvent( { 2311 sortable: this, 2312 name: 'sort', 2313 toEl: parentEl, 2314 originalEvent: evt 2315 } ); 2316 } 2317 } 2318 if ( Sortable.active ) { 2319 if ( newIndex == null || newIndex === -1 ) { 2320 newIndex = oldIndex; 2321 newDraggableIndex = oldDraggableIndex; 2322 } 2323 _dispatchEvent( { 2324 sortable: this, 2325 name: 'end', 2326 toEl: parentEl, 2327 originalEvent: evt 2328 } ); 2329 2330 // Save sorting 2331 this.save(); 2332 } 2333 } 2334 }
vendor: 4,930 bytes, lines 2335-2501
2335 this._nulling(); 2336 }, 2337 _nulling: function _nulling() { 2338 pluginEvent( 'nulling', this ); 2339 rootEl = dragEl = parentEl = ghostEl = nextEl = cloneEl = lastDownEl = cloneHidden = tapEvt = touchEvt = moved = newIndex = newDraggableIndex = oldIndex = oldDraggableIndex = lastTarget = lastDirection = putSortable = activeGroup = Sortable.dragged = Sortable.ghost = Sortable.clone = Sortable.active = null; 2340 savedInputChecked.forEach( function( el ) { 2341 el.checked = true; 2342 } ); 2343 savedInputChecked.length = lastDx = lastDy = 0; 2344 }, 2345 handleEvent: function handleEvent( /**Event*/evt ) { 2346 switch ( evt.type ) { 2347 case 'drop': 2348 case 'dragend': 2349 this._onDrop( evt ); 2350 break; 2351 case 'dragenter': 2352 case 'dragover': 2353 if ( dragEl ) { 2354 this._onDragOver( evt ); 2355 _globalDragOver( evt ); 2356 } 2357 break; 2358 case 'selectstart': 2359 evt.preventDefault(); 2360 break; 2361 } 2362 }, 2363 /** 2364 * Serializes the item into an array of string. 2365 * @returns {string[]} 2366 */ 2367 toArray: function toArray() { 2368 var order = [], 2369 el, 2370 children = this.el.children, 2371 i = 0, 2372 n = children.length, 2373 options = this.options; 2374 for ( ; i < n; i++ ) { 2375 el = children[ i ]; 2376 if ( closest( el, options.draggable, this.el, false ) ) { 2377 order.push( el.getAttribute( options.dataIdAttr ) || _generateId( el ) ); 2378 } 2379 } 2380 return order; 2381 }, 2382 /** 2383 * Sorts the elements according to the array. 2384 * @param {string[]} order Order of the items 2385 * @param {boolean} useAnimation Whether to use animations 2386 */ 2387 sort: function sort( order, useAnimation ) { 2388 var items = {}, 2389 rootEl = this.el; 2390 this.toArray().forEach( function( id, i ) { 2391 var el = rootEl.children[ i ]; 2392 if ( closest( el, this.options.draggable, rootEl, false ) ) { 2393 items[ id ] = el; 2394 } 2395 }, this ); 2396 useAnimation && this.captureAnimationState(); 2397 order.forEach( function( id ) { 2398 if ( items[ id ] ) { 2399 rootEl.removeChild( items[ id ] ); 2400 rootEl.appendChild( items[ id ] ); 2401 } 2402 } ); 2403 useAnimation && this.animateAll(); 2404 }, 2405 /** 2406 * Save the current sorting 2407 */ 2408 save: function save() { 2409 var store = this.options.store; 2410 store && store.set && store.set( this ); 2411 }, 2412 /** 2413 * 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. 2414 * @param {HTMLElement} el 2415 * @param {string} [selector] default: `options.draggable` 2416 * @returns {HTMLElement|null} 2417 */ 2418 closest: function closest$1( el, selector ) { 2419 return closest( el, selector || this.options.draggable, this.el, false ); 2420 }, 2421 /** 2422 * Set/get option 2423 * @param {string} name 2424 * @param {*} [value] 2425 * @returns {*} 2426 */ 2427 option: function option( name, value ) { 2428 var options = this.options; 2429 if ( value === void 0 ) { 2430 return options[ name ]; 2431 } 2432 var modifiedValue = PluginManager.modifyOption( this, name, value ); 2433 if ( typeof modifiedValue !== 'undefined' ) { 2434 options[ name ] = modifiedValue; 2435 } else { 2436 options[ name ] = value; 2437 } 2438 if ( name === 'group' ) { 2439 _prepareGroup( options ); 2440 } 2441 }, 2442 /** 2443 * Destroy 2444 */ 2445 destroy: function destroy() { 2446 pluginEvent( 'destroy', this ); 2447 var el = this.el; 2448 el[ expando ] = null; 2449 off( el, 'mousedown', this._onTapStart ); 2450 off( el, 'touchstart', this._onTapStart ); 2451 off( el, 'pointerdown', this._onTapStart ); 2452 if ( this.nativeDraggable ) { 2453 off( el, 'dragover', this ); 2454 off( el, 'dragenter', this ); 2455 } 2456 // Remove draggable attributes 2457 Array.prototype.forEach.call( el.querySelectorAll( '[draggable]' ), function( el ) { 2458 el.removeAttribute( 'draggable' ); 2459 } ); 2460 this._onDrop(); 2461 this._disableDelayedDragEvents(); 2462 sortables.splice( sortables.indexOf( this.el ), 1 ); 2463 this.el = el = null; 2464 }, 2465 _hideClone: function _hideClone() { 2466 if ( ! cloneHidden ) { 2467 pluginEvent( 'hideClone', this ); 2468 if ( Sortable.eventCanceled ) { 2469 return; 2470 } 2471 css( cloneEl, 'display', 'none' ); 2472 if ( this.options.removeCloneOnHide && cloneEl.parentNode ) { 2473 cloneEl.parentNode.removeChild( cloneEl ); 2474 } 2475 cloneHidden = true; 2476 } 2477 }, 2478 _showClone: function _showClone( putSortable ) { 2479 if ( putSortable.lastPutMode !== 'clone' ) { 2480 this._hideClone(); 2481 return; 2482 } 2483 if ( cloneHidden ) { 2484 pluginEvent( 'showClone', this ); 2485 if ( Sortable.eventCanceled ) { 2486 return; 2487 } 2488 2489 // show clone at dragEl or original position 2490 if ( dragEl.parentNode == rootEl && ! this.options.group.revertClone ) { 2491 rootEl.insertBefore( cloneEl, dragEl ); 2492 } else if ( nextEl ) { 2493 rootEl.insertBefore( cloneEl, nextEl ); 2494 } else { 2495 rootEl.appendChild( cloneEl ); 2496 } 2497 if ( this.options.group.revertClone ) { 2498 this.animate( dragEl, cloneEl ); 2499 } 2500 css( cloneEl, 'display', '' ); 2501 cloneHidden = false;
vendor: 5,091 bytes, lines 2502-2629
2502 } 2503 } 2504 }; 2505 function _globalDragOver( /**Event*/evt ) { 2506 if ( evt.dataTransfer ) { 2507 // evt.dataTransfer.dropEffect = 'move'; 2508 } 2509 evt.cancelable && evt.preventDefault(); 2510 } 2511 function _onMove( fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvent, willInsertAfter ) { 2512 var evt, 2513 sortable = fromEl[ expando ], 2514 onMoveFn = sortable.options.onMove, 2515 retVal; 2516 // Support for new CustomEvent feature 2517 if ( window.CustomEvent && ! IE11OrLess && ! Edge ) { 2518 evt = new CustomEvent( 'move', { 2519 bubbles: true, 2520 cancelable: true 2521 } ); 2522 } else { 2523 evt = document.createEvent( 'Event' ); 2524 evt.initEvent( 'move', true, true ); 2525 } 2526 evt.to = toEl; 2527 evt.from = fromEl; 2528 evt.dragged = dragEl; 2529 evt.draggedRect = dragRect; 2530 evt.related = targetEl || toEl; 2531 evt.relatedRect = targetRect || getRect( toEl ); 2532 evt.willInsertAfter = willInsertAfter; 2533 evt.originalEvent = originalEvent; 2534 fromEl.dispatchEvent( evt ); 2535 if ( onMoveFn ) { 2536 retVal = onMoveFn.call( sortable, evt, originalEvent ); 2537 } 2538 return retVal; 2539 } 2540 function _disableDraggable( el ) { 2541 el.draggable = false; 2542 } 2543 function _unsilent() { 2544 _silent = false; 2545 } 2546 function _ghostIsFirst( evt, vertical, sortable ) { 2547 var firstElRect = getRect( getChild( sortable.el, 0, sortable.options, true ) ); 2548 var childContainingRect = getChildContainingRectFromElement( sortable.el, sortable.options, ghostEl ); 2549 var spacer = 10; 2550 return vertical ? evt.clientX < childContainingRect.left - spacer || evt.clientY < firstElRect.top && evt.clientX < firstElRect.right : evt.clientY < childContainingRect.top - spacer || evt.clientY < firstElRect.bottom && evt.clientX < firstElRect.left; 2551 } 2552 function _ghostIsLast( evt, vertical, sortable ) { 2553 var lastElRect = getRect( lastChild( sortable.el, sortable.options.draggable ) ); 2554 var childContainingRect = getChildContainingRectFromElement( sortable.el, sortable.options, ghostEl ); 2555 var spacer = 10; 2556 return vertical ? evt.clientX > childContainingRect.right + spacer || evt.clientY > lastElRect.bottom && evt.clientX > lastElRect.left : evt.clientY > childContainingRect.bottom + spacer || evt.clientX > lastElRect.right && evt.clientY > lastElRect.top; 2557 } 2558 function _getSwapDirection( evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget ) { 2559 var mouseOnAxis = vertical ? evt.clientY : evt.clientX, 2560 targetLength = vertical ? targetRect.height : targetRect.width, 2561 targetS1 = vertical ? targetRect.top : targetRect.left, 2562 targetS2 = vertical ? targetRect.bottom : targetRect.right, 2563 invert = false; 2564 if ( ! invertSwap ) { 2565 // Never invert or create dragEl shadow when target movemenet causes mouse to move past the end of regular swapThreshold 2566 if ( isLastTarget && targetMoveDistance < targetLength * swapThreshold ) { 2567 // multiplied only by swapThreshold because mouse will already be inside target by (1 - threshold) * targetLength / 2 2568 // check if past first invert threshold on side opposite of lastDirection 2569 if ( ! pastFirstInvertThresh && ( lastDirection === 1 ? mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2 : mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2 ) ) { 2570 // past first invert threshold, do not restrict inverted threshold to dragEl shadow 2571 pastFirstInvertThresh = true; 2572 } 2573 if ( ! pastFirstInvertThresh ) { 2574 // dragEl shadow (target move distance shadow) 2575 if ( lastDirection === 1 ? mouseOnAxis < targetS1 + targetMoveDistance // over dragEl shadow 2576 : mouseOnAxis > targetS2 - targetMoveDistance ) { 2577 return -lastDirection; 2578 } 2579 } else { 2580 invert = true; 2581 } 2582 } else { 2583 // Regular 2584 if ( mouseOnAxis > targetS1 + targetLength * ( 1 - swapThreshold ) / 2 && mouseOnAxis < targetS2 - targetLength * ( 1 - swapThreshold ) / 2 ) { 2585 return _getInsertDirection( target ); 2586 } 2587 } 2588 } 2589 invert = invert || invertSwap; 2590 if ( invert ) { 2591 // Invert of regular 2592 if ( mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2 ) { 2593 return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : -1; 2594 } 2595 } 2596 return 0; 2597 } 2598 2599 /** 2600 * Gets the direction dragEl must be swapped relative to target in order to make it 2601 * seem that dragEl has been "inserted" into that element's position 2602 * @param {HTMLElement} target The target whose position dragEl is being inserted at 2603 * @return {number} Direction dragEl must be swapped 2604 */ 2605 function _getInsertDirection( target ) { 2606 if ( index( dragEl ) < index( target ) ) { 2607 return 1; 2608 } 2609 return -1; 2610 } 2611 2612 /** 2613 * Generate id 2614 * @param {HTMLElement} el 2615 * @returns {string} 2616 * @private 2617 */ 2618 function _generateId( el ) { 2619 var str = el.tagName + el.className + el.src + el.href + el.textContent, 2620 i = str.length, 2621 sum = 0; 2622 while ( i-- ) { 2623 sum += str.charCodeAt( i ); 2624 } 2625 return sum.toString( 36 ); 2626 } 2627 function _saveInputCheckedState( root ) { 2628 savedInputChecked.length = 0; 2629 var inputs = root.getElementsByTagName( 'input' );
vendor: 3,647 bytes, lines 2630-2763
2630 var idx = inputs.length; 2631 while ( idx-- ) { 2632 var el = inputs[ idx ]; 2633 el.checked && savedInputChecked.push( el ); 2634 } 2635 } 2636 function _nextTick( fn ) { 2637 return setTimeout( fn, 0 ); 2638 } 2639 function _cancelNextTick( id ) { 2640 return clearTimeout( id ); 2641 } 2642 2643 // Fixed #973: 2644 if ( documentExists ) { 2645 on( document, 'touchmove', function( evt ) { 2646 if ( ( Sortable.active || awaitingDragStarted ) && evt.cancelable ) { 2647 evt.preventDefault(); 2648 } 2649 } ); 2650 } 2651 2652 // Export utils 2653 Sortable.utils = { 2654 on: on, 2655 off: off, 2656 css: css, 2657 find: find, 2658 is: function is( el, selector ) { 2659 return !! closest( el, selector, el, false ); 2660 }, 2661 extend: extend, 2662 throttle: throttle, 2663 closest: closest, 2664 toggleClass: toggleClass, 2665 clone: clone, 2666 index: index, 2667 nextTick: _nextTick, 2668 cancelNextTick: _cancelNextTick, 2669 detectDirection: _detectDirection, 2670 getChild: getChild, 2671 expando: expando 2672 }; 2673 2674 /** 2675 * Get the Sortable instance of an element 2676 * @param {HTMLElement} element The element 2677 * @return {Sortable|undefined} The instance of Sortable 2678 */ 2679 Sortable.get = function( element ) { 2680 return element[ expando ]; 2681 }; 2682 2683 /** 2684 * Mount a plugin to Sortable 2685 */ 2686 Sortable.mount = function() { 2687 var _plugins = Array.from( arguments ); 2688 2689 if ( _plugins[ 0 ].constructor === Array ) { 2690 _plugins = _plugins[ 0 ]; 2691 } 2692 _plugins.forEach( function( plugin ) { 2693 if ( ! plugin.prototype || ! plugin.prototype.constructor ) { 2694 throw 'Sortable: Mounted plugin must be a constructor function, not '.concat( {}.toString.call( plugin ) ); 2695 } 2696 if ( plugin.utils ) { 2697 Sortable.utils = _objectSpread2( _objectSpread2( {}, Sortable.utils ), plugin.utils ); 2698 } 2699 PluginManager.mount( plugin ); 2700 } ); 2701 }; 2702 2703 /** 2704 * Create sortable instance 2705 * @param {HTMLElement} el 2706 * @param {Object} [options] 2707 */ 2708 Sortable.create = function( el, options ) { 2709 return new Sortable( el, options ); 2710 }; 2711 2712 // Export 2713 Sortable.version = version; 2714 2715 function AutoScrollPlugin() { 2716 function AutoScroll() { 2717 this.defaults = { 2718 scroll: true, 2719 forceAutoScrollFallback: false, 2720 scrollSensitivity: 30, 2721 scrollSpeed: 10, 2722 bubbleScroll: true 2723 }; 2724 2725 // Bind all private methods 2726 for ( var fn in this ) { 2727 if ( fn.charAt( 0 ) === '_' && typeof this[ fn ] === 'function' ) { 2728 this[ fn ] = this[ fn ].bind( this ); 2729 } 2730 } 2731 } 2732 AutoScroll.prototype = { 2733 dragStarted: function dragStarted( _ref ) { 2734 var originalEvent = _ref.originalEvent; 2735 if ( this.sortable.nativeDraggable ) { 2736 on( document, 'dragover', this._handleAutoScroll ); 2737 } else if ( this.options.supportPointer ) { 2738 on( document, 'pointermove', this._handleFallbackAutoScroll ); 2739 } else if ( originalEvent.touches ) { 2740 on( document, 'touchmove', this._handleFallbackAutoScroll ); 2741 } else { 2742 on( document, 'mousemove', this._handleFallbackAutoScroll ); 2743 } 2744 }, 2745 dragOverCompleted: function dragOverCompleted( _ref2 ) { 2746 var originalEvent = _ref2.originalEvent; 2747 // For when bubbling is canceled and using fallback (fallback 'touchmove' always reached) 2748 if ( ! this.options.dragOverBubble && ! originalEvent.rootEl ) { 2749 this._handleAutoScroll( originalEvent ); 2750 } 2751 }, 2752 drop: function drop() { 2753 if ( this.sortable.nativeDraggable ) { 2754 off( document, 'dragover', this._handleAutoScroll ); 2755 } else { 2756 off( document, 'pointermove', this._handleFallbackAutoScroll ); 2757 off( document, 'touchmove', this._handleFallbackAutoScroll ); 2758 off( document, 'mousemove', this._handleFallbackAutoScroll ); 2759 } 2760 clearPointerElemChangedInterval(); 2761 clearAutoScrolls(); 2762 cancelThrottle(); 2763 },
vendor: 8,945 bytes, lines 2764-3047
2764 nulling: function nulling() { 2765 touchEvt$1 = scrollRootEl = scrollEl = scrolling = pointerElemChangedInterval = lastAutoScrollX = lastAutoScrollY = null; 2766 autoScrolls.length = 0; 2767 }, 2768 _handleFallbackAutoScroll: function _handleFallbackAutoScroll( evt ) { 2769 this._handleAutoScroll( evt, true ); 2770 }, 2771 _handleAutoScroll: function _handleAutoScroll( evt, fallback ) { 2772 var _this = this; 2773 var x = ( evt.touches ? evt.touches[ 0 ] : evt ).clientX, 2774 y = ( evt.touches ? evt.touches[ 0 ] : evt ).clientY, 2775 elem = document.elementFromPoint( x, y ); 2776 touchEvt$1 = evt; 2777 2778 // IE does not seem to have native autoscroll, 2779 // Edge's autoscroll seems too conditional, 2780 // MACOS Safari does not have autoscroll, 2781 // Firefox and Chrome are good 2782 if ( fallback || this.options.forceAutoScrollFallback || Edge || IE11OrLess || Safari ) { 2783 autoScroll( evt, this.options, elem, fallback ); 2784 2785 // Listener for pointer element change 2786 var ogElemScroller = getParentAutoScrollElement( elem, true ); 2787 if ( scrolling && ( ! pointerElemChangedInterval || x !== lastAutoScrollX || y !== lastAutoScrollY ) ) { 2788 pointerElemChangedInterval && clearPointerElemChangedInterval(); 2789 // Detect for pointer elem change, emulating native DnD behaviour 2790 pointerElemChangedInterval = setInterval( function() { 2791 var newElem = getParentAutoScrollElement( document.elementFromPoint( x, y ), true ); 2792 if ( newElem !== ogElemScroller ) { 2793 ogElemScroller = newElem; 2794 clearAutoScrolls(); 2795 } 2796 autoScroll( evt, _this.options, newElem, fallback ); 2797 }, 10 ); 2798 lastAutoScrollX = x; 2799 lastAutoScrollY = y; 2800 } 2801 } else { 2802 // if DnD is enabled (and browser has good autoscrolling), first autoscroll will already scroll, so get parent autoscroll of first autoscroll 2803 if ( ! this.options.bubbleScroll || getParentAutoScrollElement( elem, true ) === getWindowScrollingElement() ) { 2804 clearAutoScrolls(); 2805 return; 2806 } 2807 autoScroll( evt, this.options, getParentAutoScrollElement( elem, false ), false ); 2808 } 2809 } 2810 }; 2811 return _extends( AutoScroll, { 2812 pluginName: 'scroll', 2813 initializeByDefault: true 2814 } ); 2815 } 2816 function clearAutoScrolls() { 2817 autoScrolls.forEach( function( _autoScroll ) { 2818 clearInterval( _autoScroll.pid ); 2819 } ); 2820 autoScrolls = []; 2821 } 2822 function clearPointerElemChangedInterval() { 2823 clearInterval( pointerElemChangedInterval ); 2824 } 2825 function Revert() {} 2826 Revert.prototype = { 2827 startIndex: null, 2828 dragStart: function dragStart( _ref2 ) { 2829 var oldDraggableIndex = _ref2.oldDraggableIndex; 2830 this.startIndex = oldDraggableIndex; 2831 }, 2832 onSpill: function onSpill( _ref3 ) { 2833 var dragEl = _ref3.dragEl, 2834 putSortable = _ref3.putSortable; 2835 this.sortable.captureAnimationState(); 2836 if ( putSortable ) { 2837 putSortable.captureAnimationState(); 2838 } 2839 var nextSibling = getChild( this.sortable.el, this.startIndex, this.options ); 2840 if ( nextSibling ) { 2841 this.sortable.el.insertBefore( dragEl, nextSibling ); 2842 } else { 2843 this.sortable.el.appendChild( dragEl ); 2844 } 2845 this.sortable.animateAll(); 2846 if ( putSortable ) { 2847 putSortable.animateAll(); 2848 } 2849 }, 2850 drop: drop 2851 }; 2852 _extends( Revert, { 2853 pluginName: 'revertOnSpill' 2854 } ); 2855 function Remove() {} 2856 Remove.prototype = { 2857 onSpill: function onSpill( _ref4 ) { 2858 var dragEl = _ref4.dragEl, 2859 putSortable = _ref4.putSortable; 2860 var parentSortable = putSortable || this.sortable; 2861 parentSortable.captureAnimationState(); 2862 dragEl.parentNode && dragEl.parentNode.removeChild( dragEl ); 2863 parentSortable.animateAll(); 2864 }, 2865 drop: drop 2866 }; 2867 _extends( Remove, { 2868 pluginName: 'removeOnSpill' 2869 } ); 2870 2871 function SwapPlugin() { 2872 function Swap() { 2873 this.defaults = { 2874 swapClass: 'sortable-swap-highlight' 2875 }; 2876 } 2877 Swap.prototype = { 2878 dragStart: function dragStart( _ref ) { 2879 var dragEl = _ref.dragEl; 2880 lastSwapEl = dragEl; 2881 }, 2882 dragOverValid: function dragOverValid( _ref2 ) { 2883 var completed = _ref2.completed, 2884 target = _ref2.target, 2885 onMove = _ref2.onMove, 2886 activeSortable = _ref2.activeSortable, 2887 changed = _ref2.changed, 2888 cancel = _ref2.cancel; 2889 if ( ! activeSortable.options.swap ) { 2890 return; 2891 } 2892 var el = this.sortable.el, 2893 options = this.options; 2894 if ( target && target !== el ) { 2895 var prevSwapEl = lastSwapEl; 2896 if ( onMove( target ) !== false ) { 2897 toggleClass( target, options.swapClass, true ); 2898 lastSwapEl = target; 2899 } else { 2900 lastSwapEl = null; 2901 } 2902 if ( prevSwapEl && prevSwapEl !== lastSwapEl ) { 2903 toggleClass( prevSwapEl, options.swapClass, false ); 2904 } 2905 } 2906 changed(); 2907 completed( true ); 2908 cancel(); 2909 }, 2910 drop: function drop( _ref3 ) { 2911 var activeSortable = _ref3.activeSortable, 2912 putSortable = _ref3.putSortable, 2913 dragEl = _ref3.dragEl; 2914 var toSortable = putSortable || this.sortable; 2915 var options = this.options; 2916 if ( lastSwapEl ) { 2917 toggleClass( lastSwapEl, options.swapClass, false ); 2918 } 2919 if ( lastSwapEl && ( options.swap || putSortable && putSortable.options.swap ) ) { 2920 if ( dragEl !== lastSwapEl ) { 2921 toSortable.captureAnimationState(); 2922 if ( toSortable !== activeSortable ) { 2923 activeSortable.captureAnimationState(); 2924 } 2925 swapNodes( dragEl, lastSwapEl ); 2926 toSortable.animateAll(); 2927 if ( toSortable !== activeSortable ) { 2928 activeSortable.animateAll(); 2929 } 2930 } 2931 } 2932 }, 2933 nulling: function nulling() { 2934 lastSwapEl = null; 2935 } 2936 }; 2937 return _extends( Swap, { 2938 pluginName: 'swap', 2939 eventProperties: function eventProperties() { 2940 return { 2941 swapItem: lastSwapEl 2942 }; 2943 } 2944 } ); 2945 } 2946 function swapNodes( n1, n2 ) { 2947 var p1 = n1.parentNode, 2948 p2 = n2.parentNode, 2949 i1, 2950 i2; 2951 if ( ! p1 || ! p2 || p1.isEqualNode( n2 ) || p2.isEqualNode( n1 ) ) { 2952 return; 2953 } 2954 i1 = index( n1 ); 2955 i2 = index( n2 ); 2956 if ( p1.isEqualNode( p2 ) && i1 < i2 ) { 2957 i2++; 2958 } 2959 p1.insertBefore( n2, p1.children[ i1 ] ); 2960 p2.insertBefore( n1, p2.children[ i2 ] ); 2961 } 2962 2963 function MultiDragPlugin() { 2964 function MultiDrag( sortable ) { 2965 // Bind all private methods 2966 for ( var fn in this ) { 2967 if ( fn.charAt( 0 ) === '_' && typeof this[ fn ] === 'function' ) { 2968 this[ fn ] = this[ fn ].bind( this ); 2969 } 2970 } 2971 if ( ! sortable.options.avoidImplicitDeselect ) { 2972 if ( sortable.options.supportPointer ) { 2973 on( document, 'pointerup', this._deselectMultiDrag ); 2974 } else { 2975 on( document, 'mouseup', this._deselectMultiDrag ); 2976 on( document, 'touchend', this._deselectMultiDrag ); 2977 } 2978 } 2979 on( document, 'keydown', this._checkKeyDown ); 2980 on( document, 'keyup', this._checkKeyUp ); 2981 this.defaults = { 2982 selectedClass: 'sortable-selected', 2983 multiDragKey: null, 2984 avoidImplicitDeselect: false, 2985 setData: function setData( dataTransfer, dragEl ) { 2986 var data = ''; 2987 if ( multiDragElements.length && multiDragSortable === sortable ) { 2988 multiDragElements.forEach( function( multiDragElement, i ) { 2989 data += ( ! i ? '' : ', ' ) + multiDragElement.textContent; 2990 } ); 2991 } else { 2992 data = dragEl.textContent; 2993 } 2994 dataTransfer.setData( 'Text', data ); 2995 } 2996 }; 2997 } 2998 MultiDrag.prototype = { 2999 multiDragKeyDown: false, 3000 isMultiDrag: false, 3001 delayStartGlobal: function delayStartGlobal( _ref ) { 3002 var dragged = _ref.dragEl; 3003 dragEl$1 = dragged; 3004 }, 3005 delayEnded: function delayEnded() { 3006 this.isMultiDrag = multiDragElements.indexOf( dragEl$1 ) !== -1; 3007 }, 3008 setupClone: function setupClone( _ref2 ) { 3009 var sortable = _ref2.sortable, 3010 cancel = _ref2.cancel; 3011 if ( ! this.isMultiDrag ) { 3012 return; 3013 } 3014 for ( var i = 0; i < multiDragElements.length; i++ ) { 3015 multiDragClones.push( clone( multiDragElements[ i ] ) ); 3016 multiDragClones[ i ].sortableIndex = multiDragElements[ i ].sortableIndex; 3017 multiDragClones[ i ].draggable = false; 3018 multiDragClones[ i ].style[ 'will-change' ] = ''; 3019 toggleClass( multiDragClones[ i ], this.options.selectedClass, false ); 3020 multiDragElements[ i ] === dragEl$1 && toggleClass( multiDragClones[ i ], this.options.chosenClass, false ); 3021 } 3022 sortable._hideClone(); 3023 cancel(); 3024 }, 3025 clone: function clone( _ref3 ) { 3026 var sortable = _ref3.sortable, 3027 rootEl = _ref3.rootEl, 3028 dispatchSortableEvent = _ref3.dispatchSortableEvent, 3029 cancel = _ref3.cancel; 3030 if ( ! this.isMultiDrag ) { 3031 return; 3032 } 3033 if ( ! this.options.removeCloneOnHide ) { 3034 if ( multiDragElements.length && multiDragSortable === sortable ) { 3035 insertMultiDragClones( true, rootEl ); 3036 dispatchSortableEvent( 'clone' ); 3037 cancel(); 3038 } 3039 } 3040 }, 3041 showClone: function showClone( _ref4 ) { 3042 var cloneNowShown = _ref4.cloneNowShown, 3043 rootEl = _ref4.rootEl, 3044 cancel = _ref4.cancel; 3045 if ( ! this.isMultiDrag ) { 3046 return; 3047 }
3048 insertMultiDragClones( false, rootEl ); 3049 multiDragClones.forEach( function( _clone ) { 3050 css( _clone, 'display', '' ); 3051 } ); 3052 cloneNowShown(); 3053 clonesHidden = false; 3054 cancel(); 3055 }, 3056 hideClone: function hideClone( _ref5 ) { 3057 var _this = this; 3058 var sortable = _ref5.sortable, 3059 cloneNowHidden = _ref5.cloneNowHidden, 3060 cancel = _ref5.cancel; 3061 if ( ! this.isMultiDrag ) { 3062 return; 3063 } 3064 multiDragClones.forEach( function( _clone ) { 3065 css( _clone, 'display', 'none' ); 3066 if ( _clone.options.removeCloneOnHide && _clone.parentNode ) { 3067 clone.parentNode.removeChild( _clone ); 3068 } 3069 } ); 3070 cloneNowHidden(); 3071 clonesHidden = true; 3072 cancel(); 3073 }, 3074 dragStartGlobal: function dragStartGlobal( _ref6 ) { 3075 var sortable = _ref6.sortable; 3076 if ( ! this.isMultiDrag && multiDragSortable ) { 3077 multiDragSortable.multiDrag._deselectMultiDrag(); 3078 } 3079 multiDragElements.forEach( function( multiDragElement ) { 3080 multiDragElement.sortableIndex = index( multiDragElement ); 3081 } ); 3082 3083 // Sort multi-drag elements 3084 multiDragElements = multiDragElements.sort( function( a, b ) { 3085 return a.sortableIndex - b.sortableIndex; 3086 } ); 3087 dragStarted = true; 3088 }, 3089 dragStarted: function( _ref7 ) { 3090 var _this2 = this; 3091 var sortable = _ref7.sortable; 3092 var dragRect; 3093 if ( ! this.isMultiDrag ) { 3094 return; 3095 } 3096 if ( this.options.sort ) { 3097 // Capture rects, 3098 // hide multi drag elements (by positioning them absolute), 3099 // set multi drag elements rects to dragRect, 3100 // show multi drag elements, 3101 // animate to rects, 3102 // unset rects & remove from DOM 3103 3104 sortable.captureAnimationState(); 3105 if ( this.options.animation ) { 3106 multiDragElements.forEach( function( multiDragElement ) { 3107 if ( multiDragElement === dragEl$1 ) { 3108 return; 3109 } 3110 css( multiDragElement, 'position', 'absolute' ); 3111 } ); 3112 dragRect = getRect( dragEl$1, false, true, true ); 3113 multiDragElements.forEach( function( multiDragElement ) { 3114 if ( multiDragElement === dragEl$1 ) { 3115 return; 3116 } 3117 setRect( multiDragElement, dragRect ); 3118 } ); 3119 folding = true; 3120 initialFolding = true; 3121 } 3122 } 3123 sortable.animateAll( function() { 3124 folding = false; 3125 initialFolding = false; 3126 if ( _this2.options.animation ) { 3127 multiDragElements.forEach( function( multiDragElement ) { 3128 unsetRect( multiDragElement ); 3129 } ); 3130 } 3131 3132 // Remove all auxiliary multidrag items from el, if sorting enabled 3133 if ( _this2.options.sort ) { 3134 removeMultiDragElements(); 3135 } 3136 } ); 3137 }, 3138 dragOver: function dragOver( _ref8 ) { 3139 var target = _ref8.target, 3140 completed = _ref8.completed, 3141 cancel = _ref8.cancel; 3142 if ( folding && multiDragElements.indexOf( target ) !== -1 ) { 3143 completed( false ); 3144 cancel(); 3145 } 3146 }, 3147 revert: function revert( _ref9 ) { 3148 var fromSortable = _ref9.fromSortable, 3149 _rootEl = _ref9.rootEl, 3150 sortable = _ref9.sortable, 3151 dragRect = _ref9.dragRect; 3152 if ( multiDragElements.length > 1 ) { 3153 // Setup unfold animation 3154 multiDragElements.forEach( function( multiDragElement ) { 3155 sortable.addAnimationState( { 3156 target: multiDragElement, 3157 rect: folding ? getRect( multiDragElement ) : dragRect 3158 } ); 3159 unsetRect( multiDragElement ); 3160 multiDragElement.fromRect = dragRect; 3161 fromSortable.removeAnimationState( multiDragElement ); 3162 } ); 3163 folding = false; 3164 insertMultiDragElements( ! this.options.removeCloneOnHide, _rootEl ); 3165 } 3166 }, 3167 dragOverCompleted: function dragOverCompleted( _ref10 ) { 3168 var sortable = _ref10.sortable, 3169 isOwner = _ref10.isOwner, 3170 insertion = _ref10.insertion, 3171 activeSortable = _ref10.activeSortable, 3172 _parentEl = _ref10.parentEl, 3173 _putSortable = _ref10.putSortable; 3174 var options = this.options; 3175 var dragRectAbsolute; 3176 var clonesHiddenBefore; 3177 if ( insertion ) { 3178 // Clones must be hidden before folding animation to capture dragRectAbsolute properly 3179 if ( isOwner ) { 3180 activeSortable._hideClone(); 3181 } 3182 initialFolding = false;
3183 // If leaving sort:false root, or already folding - Fold to new location 3184 if ( options.animation && multiDragElements.length > 1 && ( folding || ( ! isOwner && ! activeSortable.options.sort && ! _putSortable ) ) ) { 3185 // Fold: Set all multi drag elements's rects to dragEl's rect when multi-drag elements are invisible 3186 dragRectAbsolute = getRect( dragEl$1, false, true, true ); 3187 multiDragElements.forEach( function( multiDragElement ) { 3188 if ( multiDragElement === dragEl$1 ) { 3189 return; 3190 } 3191 setRect( multiDragElement, dragRectAbsolute ); 3192 3193 // Move element(s) to end of _parentEl so that it does not interfere with multi-drag clones insertion if they are inserted 3194 // while folding, and so that we can capture them again because old sortable will no longer be fromSortable 3195 _parentEl.appendChild( multiDragElement ); 3196 } ); 3197 folding = true; 3198 } 3199 3200 // Clones must be shown (and check to remove multi drags) after folding when interfering multiDragElements are moved out 3201 if ( ! isOwner ) { 3202 // Only remove if not folding (folding will remove them anyways) 3203 if ( ! folding ) { 3204 removeMultiDragElements(); 3205 } 3206 if ( multiDragElements.length > 1 ) { 3207 clonesHiddenBefore = clonesHidden; 3208 activeSortable._showClone( sortable ); 3209 3210 // Unfold animation for clones if showing from hidden 3211 if ( activeSortable.options.animation && ! clonesHidden && clonesHiddenBefore ) { 3212 multiDragClones.forEach( function( _clone ) { 3213 activeSortable.addAnimationState( { 3214 target: _clone, 3215 rect: clonesFromRect 3216 } ); 3217 _clone.fromRect = clonesFromRect; 3218 _clone.thisAnimationDuration = null; 3219 } ); 3220 } 3221 } else { 3222 activeSortable._showClone( sortable ); 3223 } 3224 } 3225 } 3226 }, 3227 dragOverAnimationCapture: function dragOverAnimationCapture( _ref11 ) { 3228 var dragRect = _ref11.dragRect, 3229 isOwner = _ref11.isOwner, 3230 activeSortable = _ref11.activeSortable, 3231 dragMatrix; 3232 multiDragElements.forEach( function( multiDragElement ) { 3233 multiDragElement.thisAnimationDuration = null; 3234 } ); 3235 if ( activeSortable.options.animation && ! isOwner && activeSortable.multiDrag.isMultiDrag ) { 3236 clonesFromRect = _extends( {}, dragRect ); 3237 dragMatrix = matrix( dragEl$1, true ); 3238 clonesFromRect.top -= dragMatrix.f; 3239 clonesFromRect.left -= dragMatrix.e; 3240 } 3241 }, 3242 dragOverAnimationComplete: function dragOverAnimationComplete() { 3243 if ( folding ) { 3244 folding = false; 3245 removeMultiDragElements(); 3246 } 3247 }, 3248 drop: function( _ref12 ) { 3249 var evt = _ref12.originalEvent, 3250 _rootEl = _ref12.rootEl, 3251 _parentEl = _ref12.parentEl, 3252 sortable = _ref12.sortable, 3253 dispatchSortableEvent = _ref12.dispatchSortableEvent, 3254 _oldIndex = _ref12.oldIndex, 3255 _putSortable = _ref12.putSortable; 3256 var toSortable = _putSortable || this.sortable; 3257 var options; 3258 var children; 3259 var update; 3260 var lastIndex; 3261 var currentIndex; 3262 var filter; 3263 var filtered; 3264 var dragRect; 3265 var multiDragIndex; 3266 var rect; 3267 if ( ! evt ) { 3268 return; 3269 } 3270 options = this.options; 3271 children = _parentEl.children; 3272 3273 // Multi-drag selection 3274 if ( ! dragStarted ) { 3275 if ( options.multiDragKey && ! this.multiDragKeyDown ) { 3276 this._deselectMultiDrag(); 3277 } 3278 toggleClass( dragEl$1, options.selectedClass, multiDragElements.indexOf( dragEl$1 ) === -1 ); 3279 if ( multiDragElements.indexOf( dragEl$1 ) === -1 ) { 3280 multiDragElements.push( dragEl$1 ); 3281 dispatchEvent( { 3282 sortable: sortable, 3283 rootEl: _rootEl, 3284 name: 'select', 3285 targetEl: dragEl$1, 3286 originalEvent: evt 3287 } ); 3288 3289 // Modifier activated, select from last to dragEl 3290 if ( evt.shiftKey && lastMultiDragSelect && sortable.el.contains( lastMultiDragSelect ) ) { 3291 lastIndex = index( lastMultiDragSelect ); 3292 currentIndex = index( dragEl$1 ); 3293 if ( lastIndex !== -1 && currentIndex !== -1 && lastIndex !== currentIndex ) { 3294 ( function() { 3295 // Must include lastMultiDragSelect (select it), in case modified selection from no selection 3296 // (but previous selection existed) 3297 var n, i; 3298 if ( currentIndex > lastIndex ) { 3299 i = lastIndex; 3300 n = currentIndex; 3301 } else { 3302 i = currentIndex; 3303 n = lastIndex + 1; 3304 } 3305 filter = options.filter; 3306 for ( ; i < n; i++ ) { 3307 if ( multiDragElements.indexOf( children[ i ] ) !== -1 ) { 3308 continue; 3309 } 3310 // Check if element is draggable 3311 if ( ! closest( children[ i ], options.draggable, _parentEl, false ) ) { 3312 continue; 3313 } 3314 // Check if element is filtered 3315 filtered = filter && ( typeof filter === 'function' ? filter.call( sortable, evt, children[ i ], sortable ) : filter.split( ',' ).some( function( criteria ) { 3316 return closest( children[ i ], criteria.trim(), _parentEl, false ); 3317 } ) ); 3318 if ( filtered ) { 3319 continue; 3320 } 3321 toggleClass( children[ i ], options.selectedClass, true ); 3322 multiDragElements.push( children[ i ] ); 3323 dispatchEvent( {
3324 sortable: sortable, 3325 rootEl: _rootEl, 3326 name: 'select', 3327 targetEl: children[ i ], 3328 originalEvent: evt 3329 } ); 3330 } 3331 }() ); 3332 } 3333 } else { 3334 lastMultiDragSelect = dragEl$1; 3335 } 3336 multiDragSortable = toSortable; 3337 } else { 3338 multiDragElements.splice( multiDragElements.indexOf( dragEl$1 ), 1 ); 3339 lastMultiDragSelect = null; 3340 dispatchEvent( { 3341 sortable: sortable, 3342 rootEl: _rootEl, 3343 name: 'deselect', 3344 targetEl: dragEl$1, 3345 originalEvent: evt 3346 } ); 3347 } 3348 } 3349 3350 // Multi-drag drop 3351 if ( dragStarted && this.isMultiDrag ) { 3352 folding = false; 3353 // Do not "unfold" after around dragEl if reverted 3354 if ( ( _parentEl[ expando ].options.sort || _parentEl !== _rootEl ) && multiDragElements.length > 1 ) { 3355 dragRect = getRect( dragEl$1 ); 3356 multiDragIndex = index( dragEl$1, ':not(.' + this.options.selectedClass + ')' ); 3357 if ( ! initialFolding && options.animation ) { 3358 dragEl$1.thisAnimationDuration = null; 3359 } 3360 toSortable.captureAnimationState(); 3361 if ( ! initialFolding ) { 3362 if ( options.animation ) { 3363 dragEl$1.fromRect = dragRect; 3364 multiDragElements.forEach( function( multiDragElement ) { 3365 multiDragElement.thisAnimationDuration = null; 3366 if ( multiDragElement !== dragEl$1 ) { 3367 rect = folding ? getRect( multiDragElement ) : dragRect; 3368 multiDragElement.fromRect = rect; 3369 3370 // Prepare unfold animation 3371 toSortable.addAnimationState( { 3372 target: multiDragElement, 3373 rect: rect 3374 } ); 3375 } 3376 } ); 3377 } 3378 3379 // Multi drag elements are not necessarily removed from the DOM on drop, so to reinsert 3380 // properly they must all be removed 3381 removeMultiDragElements(); 3382 multiDragElements.forEach( function( multiDragElement ) { 3383 if ( children[ multiDragIndex ] ) { 3384 _parentEl.insertBefore( multiDragElement, children[ multiDragIndex ] ); 3385 } else { 3386 _parentEl.appendChild( multiDragElement ); 3387 } 3388 multiDragIndex++; 3389 } ); 3390 3391 // If initial folding is done, the elements may have changed position because they are now 3392 // unfolding around dragEl, even though dragEl may not have his index changed, so update event 3393 // must be fired here as Sortable will not. 3394 if ( _oldIndex === index( dragEl$1 ) ) { 3395 update = false; 3396 multiDragElements.forEach( function( multiDragElement ) { 3397 if ( multiDragElement.sortableIndex !== index( multiDragElement ) ) { 3398 update = true; 3399 } 3400 } ); 3401 if ( update ) { 3402 dispatchSortableEvent( 'update' ); 3403 dispatchSortableEvent( 'sort' ); 3404 } 3405 } 3406 } 3407 3408 // Must be done after capturing individual rects (scroll bar) 3409 multiDragElements.forEach( function( multiDragElement ) { 3410 unsetRect( multiDragElement ); 3411 } ); 3412 toSortable.animateAll(); 3413 } 3414 multiDragSortable = toSortable; 3415 } 3416 3417 // Remove clones if necessary 3418 if ( _rootEl === _parentEl || ( _putSortable && _putSortable.lastPutMode !== 'clone' ) ) { 3419 multiDragClones.forEach( function( _clone ) { 3420 if ( _clone.parentNode ) { 3421 _clone.parentNode.removeChild( _clone ); 3422 } 3423 } ); 3424 } 3425 }, 3426 nullingGlobal: function nullingGlobal() { 3427 this.isMultiDrag = dragStarted = false; 3428 multiDragClones.length = 0; 3429 }, 3430 destroyGlobal: function destroyGlobal() { 3431 this._deselectMultiDrag(); 3432 off( document, 'pointerup', this._deselectMultiDrag ); 3433 off( document, 'mouseup', this._deselectMultiDrag ); 3434 off( document, 'touchend', this._deselectMultiDrag ); 3435 off( document, 'keydown', this._checkKeyDown ); 3436 off( document, 'keyup', this._checkKeyUp ); 3437 }, 3438 _deselectMultiDrag: function _deselectMultiDrag( evt ) { 3439 var el; 3440 if ( typeof dragStarted !== 'undefined' && dragStarted ) { 3441 return; 3442 } 3443 3444 // Only deselect if selection is in this sortable 3445 if ( multiDragSortable !== this.sortable ) { 3446 return; 3447 } 3448 3449 // Only deselect if target is not item in this sortable 3450 if ( evt && closest( evt.target, this.options.draggable, this.sortable.el, false ) ) { 3451 return; 3452 } 3453 3454 // Only deselect if left click 3455 if ( evt && evt.button !== 0 ) { 3456 return; 3457 } 3458 while ( multiDragElements.length ) { 3459 el = multiDragElements[ 0 ]; 3460 toggleClass( el, this.options.selectedClass, false ); 3461 multiDragElements.shift(); 3462 dispatchEvent( { 3463 sortable: this.sortable, 3464 rootEl: this.sortable.el, 3465 name: 'deselect', 3466 targetEl: el, 3467 originalEvent: evt 3468 } ); 3469 } 3470 }, 3471 _checkKeyDown: function _checkKeyDown( evt ) { 3472 if ( evt.key === this.options.multiDragKey ) { 3473 this.multiDragKeyDown = true; 3474 } 3475 }, 3476 _checkKeyUp: function _checkKeyUp( evt ) { 3477 if ( evt.key === this.options.multiDragKey ) { 3478 this.multiDragKeyDown = false;
3479 } 3480 } 3481 }; 3482 return _extends( MultiDrag, { 3483 // Static methods & properties 3484 pluginName: 'multiDrag', 3485 utils: { 3486 /** 3487 * Selects the provided multi-drag item 3488 * @param {HTMLElement} el The element to be selected 3489 */ 3490 select: function select( el ) { 3491 var sortable = el.parentNode[ expando ]; 3492 if ( ! sortable || ! sortable.options.multiDrag || multiDragElements.indexOf( el ) !== -1 ) { 3493 return; 3494 } 3495 if ( multiDragSortable && multiDragSortable !== sortable ) { 3496 multiDragSortable.multiDrag._deselectMultiDrag(); 3497 multiDragSortable = sortable; 3498 } 3499 toggleClass( el, sortable.options.selectedClass, true ); 3500 multiDragElements.push( el ); 3501 }, 3502 /** 3503 * Deselects the provided multi-drag item 3504 * @param {HTMLElement} el The element to be deselected 3505 */ 3506 deselect: function deselect( el ) { 3507 var sortable = el.parentNode[ expando ], 3508 _index = multiDragElements.indexOf( el ); 3509 if ( ! sortable || ! sortable.options.multiDrag || _index === -1 ) { 3510 return; 3511 } 3512 toggleClass( el, sortable.options.selectedClass, false ); 3513 multiDragElements.splice( _index, 1 ); 3514 } 3515 }, 3516 eventProperties: function eventProperties() { 3517 var _this3 = this; 3518 var oldIndicies = [], 3519 newIndicies = []; 3520 var _newIndex; 3521 multiDragElements.forEach( function( multiDragElement ) { 3522 oldIndicies.push( { 3523 multiDragElement: multiDragElement, 3524 index: multiDragElement.sortableIndex 3525 } ); 3526 3527 // multiDragElements will already be sorted if folding 3528 if ( folding && multiDragElement !== dragEl$1 ) { 3529 _newIndex = -1; 3530 } else if ( folding ) { 3531 _newIndex = index( multiDragElement, ':not(.' + _this3.options.selectedClass + ')' ); 3532 } else { 3533 _newIndex = index( multiDragElement ); 3534 } 3535 newIndicies.push( { 3536 multiDragElement: multiDragElement, 3537 index: _newIndex 3538 } ); 3539 } ); 3540 return { 3541 items: _toConsumableArray( multiDragElements ), 3542 clones: [].concat( multiDragClones ), 3543 oldIndicies: oldIndicies, 3544 newIndicies: newIndicies 3545 }; 3546 }, 3547 optionListeners: { 3548 multiDragKey: function multiDragKey( key ) { 3549 key = key.toLowerCase(); 3550 if ( key === 'ctrl' ) { 3551 key = 'Control'; 3552 } else if ( key.length > 1 ) { 3553 key = key.charAt( 0 ).toUpperCase() + key.substr( 1 ); 3554 } 3555 return key; 3556 } 3557 } 3558 } ); 3559 } 3560 function insertMultiDragElements( clonesInserted, _rootEl ) { 3561 multiDragElements.forEach( function( multiDragElement, i ) { 3562 var target = _rootEl.children[ multiDragElement.sortableIndex + ( clonesInserted ? Number( i ) : 0 ) ]; 3563 if ( target ) { 3564 _rootEl.insertBefore( multiDragElement, target ); 3565 } else { 3566 _rootEl.appendChild( multiDragElement ); 3567 } 3568 } ); 3569 } 3570 3571 /** 3572 * Insert multi-drag clones 3573 * @param {[boolean]} elementsInserted Whether the multi-drag elements are inserted 3574 * @param {HTMLElement} _rootEl 3575 */ 3576 function insertMultiDragClones( elementsInserted, _rootEl ) { 3577 multiDragClones.forEach( function( _clone, i ) { 3578 var target = _rootEl.children[ clone.sortableIndex + ( elementsInserted ? Number( i ) : 0 ) ]; 3579 if ( target ) { 3580 _rootEl.insertBefore( _clone, target ); 3581 } else { 3582 _rootEl.appendChild( _clone ); 3583 } 3584 } ); 3585 } 3586 function removeMultiDragElements() { 3587 multiDragElements.forEach( function( multiDragElement ) { 3588 if ( multiDragElement === dragEl$1 ) { 3589 return; 3590 } 3591 if ( multiDragElement && multiDragElement.parentNode ) { 3592 multiDragElement.parentNode.removeChild( multiDragElement ); 3593 } 3594 } ); 3595 } 3596 3597 Sortable.mount( new AutoScrollPlugin() ); 3598 Sortable.mount( Remove, Revert ); 3599 3600 Sortable.mount( new SwapPlugin() ); 3601 Sortable.mount( new MultiDragPlugin() ); 3602 3603 return Sortable; 3604} ) ) ); 3605 3606( function( factory ) { 3607 'use strict'; 3608 var sortable, 3609 jq; 3610 3611 if ( typeof define === 'function' && define.amd ) { 3612 try { 3613 define( [ 'sortablejs', 'jquery' ], function( Sortable, $ ) { 3614 sortable = Sortable; 3615 jq = $; 3616 checkErrors(); 3617 factory( Sortable, $ ); 3618 } ); 3619 } catch ( err ) { 3620 checkErrors(); 3621 } 3622 return; 3623 } else if ( typeof exports === 'object' ) { 3624 try { 3625 sortable = require( 'sortablejs' ); 3626 jq = require( 'jquery' ); 3627 } catch ( err ) { } 3628 } 3629 3630 if ( typeof window.jQuery === 'function' || typeof $ === 'function' ) { 3631 jq = window.jQuery || window.$; 3632 } 3633 3634 if ( typeof window.Sortable !== 'undefined' ) { 3635 sortable = window.Sortable; 3636 } 3637 3638 function checkErrors() { 3639 if ( ! jq ) { 3640 throw new Error( 'jQuery is required for jquery-sortablejs' ); 3641 } 3642 3643 if ( ! sortable ) { 3644 throw new Error( 'SortableJS is required for jquery-sortablejs (https://github.com/SortableJS/Sortable)' ); 3645 } 3646 } 3647 checkErrors(); 3648 factory( sortable, jq ); 3649}( function( Sortable, $ ) { 3650 'use strict'; 3651 3652 $.fn.sortablejs = function( options ) { 3653 var retVal, 3654 args = arguments; 3655 3656 this.each( function() { 3657 var $el = $( this ), 3658 sortable = $el.data( 'sortable' ); 3659 3660 if ( ! sortable && ( options instanceof Object || ! options ) ) { 3661 sortable = new Sortable( this, options ); 3662 $el.data( 'sortable', sortable ); 3663 $el.addClass( 'ui-sortable' ); 3664 } else if ( sortable ) { 3665 if ( options === 'destroy' ) { 3666 sortable.destroy(); 3667 $el.removeData( 'sortable' ); 3668 $el.removeClass( 'ui-sortable' ); 3669 } else if ( options === 'widget' ) { 3670 retVal = sortable; 3671 } else if ( typeof sortable[ options ] === 'function' ) { 3672 retVal = sortable[ options ].apply( sortable, [].slice.call( args, 1 ) ); 3673 }
3673 else if ( options in sortable.options ) { 3674 retVal = sortable.option.apply( sortable, args ); 3675 } 3676 } 3677 } ); 3678 3679 return ( retVal === void 0 ) ? this : retVal; 3680 }; 3681} ) );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.