wp/wp-includes/js/jquery/ui/sortable.js
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
     1 /*!
     1 /*!
     2  * jQuery UI Sortable 1.13.1
     2  * jQuery UI Sortable 1.13.3
     3  * http://jqueryui.com
     3  * https://jqueryui.com
     4  *
     4  *
     5  * Copyright jQuery Foundation and other contributors
     5  * Copyright OpenJS Foundation and other contributors
     6  * Released under the MIT license.
     6  * Released under the MIT license.
     7  * http://jquery.org/license
     7  * https://jquery.org/license
     8  */
     8  */
     9 
     9 
    10 //>>label: Sortable
    10 //>>label: Sortable
    11 //>>group: Interactions
    11 //>>group: Interactions
    12 //>>description: Enables items in a list to be sorted using the mouse.
    12 //>>description: Enables items in a list to be sorted using the mouse.
    13 //>>docs: http://api.jqueryui.com/sortable/
    13 //>>docs: https://api.jqueryui.com/sortable/
    14 //>>demos: http://jqueryui.com/sortable/
    14 //>>demos: https://jqueryui.com/sortable/
    15 //>>css.structure: ../../themes/base/sortable.css
    15 //>>css.structure: ../../themes/base/sortable.css
    16 
    16 
    17 ( function( factory ) {
    17 ( function( factory ) {
    18 	"use strict";
    18 	"use strict";
    19 
    19 
    21 
    21 
    22 		// AMD. Register as an anonymous module.
    22 		// AMD. Register as an anonymous module.
    23 		define( [
    23 		define( [
    24 			"jquery",
    24 			"jquery",
    25 			"./mouse",
    25 			"./mouse",
    26 			"./core"
    26 			"../data",
       
    27 			"../ie",
       
    28 			"../scroll-parent",
       
    29 			"../version",
       
    30 			"../widget"
    27 		], factory );
    31 		], factory );
    28 	} else {
    32 	} else {
    29 
    33 
    30 		// Browser globals
    34 		// Browser globals
    31 		factory( jQuery );
    35 		factory( jQuery );
    32 	}
    36 	}
    33 } )( function( $ ) {
    37 } )( function( $ ) {
    34 "use strict";
    38 "use strict";
    35 
    39 
    36 return $.widget( "ui.sortable", $.ui.mouse, {
    40 return $.widget( "ui.sortable", $.ui.mouse, {
    37 	version: "1.13.1",
    41 	version: "1.13.3",
    38 	widgetEventPrefix: "sort",
    42 	widgetEventPrefix: "sort",
    39 	ready: false,
    43 	ready: false,
    40 	options: {
    44 	options: {
    41 		appendTo: "parent",
    45 		appendTo: "parent",
    42 		axis: false,
    46 		axis: false,
   194 		// mouseCapture
   198 		// mouseCapture
   195 		this.refreshPositions();
   199 		this.refreshPositions();
   196 
   200 
   197 		//Prepare the dragged items parent
   201 		//Prepare the dragged items parent
   198 		this.appendTo = $( o.appendTo !== "parent" ?
   202 		this.appendTo = $( o.appendTo !== "parent" ?
   199 			o.appendTo :
   203 				o.appendTo :
   200 			this.currentItem.parent() );
   204 				this.currentItem.parent() );
   201 
   205 
   202 		//Create and append the visible helper
   206 		//Create and append the visible helper
   203 		this.helper = this._createHelper( event );
   207 		this.helper = this._createHelper( event );
   204 
   208 
   205 		//Cache the helper size
   209 		//Cache the helper size
   297 			this.helper.css( "opacity", o.opacity );
   301 			this.helper.css( "opacity", o.opacity );
   298 		}
   302 		}
   299 
   303 
   300 		//Prepare scrolling
   304 		//Prepare scrolling
   301 		if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
   305 		if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
   302 			this.scrollParent[ 0 ].tagName !== "HTML" ) {
   306 				this.scrollParent[ 0 ].tagName !== "HTML" ) {
   303 			this.overflowOffset = this.scrollParent.offset();
   307 			this.overflowOffset = this.scrollParent.offset();
   304 		}
   308 		}
   305 
   309 
   306 		//Call callbacks
   310 		//Call callbacks
   307 		this._trigger( "start", event, this._uiHash() );
   311 		this._trigger( "start", event, this._uiHash() );
   354 	_scroll: function( event ) {
   358 	_scroll: function( event ) {
   355 		var o = this.options,
   359 		var o = this.options,
   356 			scrolled = false;
   360 			scrolled = false;
   357 
   361 
   358 		if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
   362 		if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
   359 			this.scrollParent[ 0 ].tagName !== "HTML" ) {
   363 				this.scrollParent[ 0 ].tagName !== "HTML" ) {
   360 
   364 
   361 			if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) -
   365 			if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) -
   362 				event.pageY < o.scrollSensitivity ) {
   366 					event.pageY < o.scrollSensitivity ) {
   363 				this.scrollParent[ 0 ].scrollTop =
   367 				this.scrollParent[ 0 ].scrollTop =
   364 					scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed;
   368 					scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed;
   365 			} else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) {
   369 			} else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) {
   366 				this.scrollParent[ 0 ].scrollTop =
   370 				this.scrollParent[ 0 ].scrollTop =
   367 					scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed;
   371 					scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed;
   368 			}
   372 			}
   369 
   373 
   370 			if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) -
   374 			if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) -
   371 				event.pageX < o.scrollSensitivity ) {
   375 					event.pageX < o.scrollSensitivity ) {
   372 				this.scrollParent[ 0 ].scrollLeft = scrolled =
   376 				this.scrollParent[ 0 ].scrollLeft = scrolled =
   373 					this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed;
   377 					this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed;
   374 			} else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) {
   378 			} else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) {
   375 				this.scrollParent[ 0 ].scrollLeft = scrolled =
   379 				this.scrollParent[ 0 ].scrollLeft = scrolled =
   376 					this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed;
   380 					this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed;
   379 		} else {
   383 		} else {
   380 
   384 
   381 			if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) {
   385 			if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) {
   382 				scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed );
   386 				scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed );
   383 			} else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) <
   387 			} else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) <
   384 				o.scrollSensitivity ) {
   388 					o.scrollSensitivity ) {
   385 				scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed );
   389 				scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed );
   386 			}
   390 			}
   387 
   391 
   388 			if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) {
   392 			if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) {
   389 				scrolled = this.document.scrollLeft(
   393 				scrolled = this.document.scrollLeft(
   390 					this.document.scrollLeft() - o.scrollSpeed
   394 					this.document.scrollLeft() - o.scrollSpeed
   391 				);
   395 				);
   392 			} else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) <
   396 			} else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) <
   393 				o.scrollSensitivity ) {
   397 					o.scrollSensitivity ) {
   394 				scrolled = this.document.scrollLeft(
   398 				scrolled = this.document.scrollLeft(
   395 					this.document.scrollLeft() + o.scrollSpeed
   399 					this.document.scrollLeft() + o.scrollSpeed
   396 				);
   400 				);
   397 			}
   401 			}
   398 
   402 
   460 			// Cannot intersect with itself
   464 			// Cannot intersect with itself
   461 			// no useless actions that have been done before
   465 			// no useless actions that have been done before
   462 			// no action if the item moved is the parent of the item checked
   466 			// no action if the item moved is the parent of the item checked
   463 			if ( itemElement !== this.currentItem[ 0 ] &&
   467 			if ( itemElement !== this.currentItem[ 0 ] &&
   464 				this.placeholder[ intersection === 1 ?
   468 				this.placeholder[ intersection === 1 ?
   465 					"next" : "prev" ]()[ 0 ] !== itemElement &&
   469 				"next" : "prev" ]()[ 0 ] !== itemElement &&
   466 				!$.contains( this.placeholder[ 0 ], itemElement ) &&
   470 				!$.contains( this.placeholder[ 0 ], itemElement ) &&
   467 				( this.options.type === "semi-dynamic" ?
   471 				( this.options.type === "semi-dynamic" ?
   468 						!$.contains( this.element[ 0 ], itemElement ) :
   472 					!$.contains( this.element[ 0 ], itemElement ) :
   469 						true
   473 					true
   470 				)
   474 				)
   471 			) {
   475 			) {
   472 
   476 
   473 				this.direction = intersection === 1 ? "down" : "up";
   477 				this.direction = intersection === 1 ? "down" : "up";
   474 
   478 
   475 				if ( this.options.tolerance === "pointer" ||
   479 				if ( this.options.tolerance === "pointer" ||
   476 					this._intersectsWithSides( item ) ) {
   480 						this._intersectsWithSides( item ) ) {
   477 					this._rearrange( event, item );
   481 					this._rearrange( event, item );
   478 				} else {
   482 				} else {
   479 					break;
   483 					break;
   480 				}
   484 				}
   481 
   485 
   518 				animation = {};
   522 				animation = {};
   519 
   523 
   520 			if ( !axis || axis === "x" ) {
   524 			if ( !axis || axis === "x" ) {
   521 				animation.left = cur.left - this.offset.parent.left - this.margins.left +
   525 				animation.left = cur.left - this.offset.parent.left - this.margins.left +
   522 					( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
   526 					( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
   523 							0 :
   527 						0 :
   524 							this.offsetParent[ 0 ].scrollLeft
   528 						this.offsetParent[ 0 ].scrollLeft
   525 					);
   529 					);
   526 			}
   530 			}
   527 			if ( !axis || axis === "y" ) {
   531 			if ( !axis || axis === "y" ) {
   528 				animation.top = cur.top - this.offset.parent.top - this.margins.top +
   532 				animation.top = cur.top - this.offset.parent.top - this.margins.top +
   529 					( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
   533 					( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
   530 							0 :
   534 						0 :
   531 							this.offsetParent[ 0 ].scrollTop
   535 						this.offsetParent[ 0 ].scrollTop
   532 					);
   536 					);
   533 			}
   537 			}
   534 			this.reverting = true;
   538 			this.reverting = true;
   535 			$( this.helper ).animate(
   539 			$( this.helper ).animate(
   536 				animation,
   540 				animation,
   577 			// it unbinds ALL events from the original node!
   581 			// it unbinds ALL events from the original node!
   578 			if ( this.placeholder[ 0 ].parentNode ) {
   582 			if ( this.placeholder[ 0 ].parentNode ) {
   579 				this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
   583 				this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
   580 			}
   584 			}
   581 			if ( this.options.helper !== "original" && this.helper &&
   585 			if ( this.options.helper !== "original" && this.helper &&
   582 				this.helper[ 0 ].parentNode ) {
   586 					this.helper[ 0 ].parentNode ) {
   583 				this.helper.remove();
   587 				this.helper.remove();
   584 			}
   588 			}
   585 
   589 
   586 			$.extend( this, {
   590 			$.extend( this, {
   587 				helper: null,
   591 				helper: null,
   853 		for ( i = this.items.length - 1; i >= 0; i-- ) {
   857 		for ( i = this.items.length - 1; i >= 0; i-- ) {
   854 			item = this.items[ i ];
   858 			item = this.items[ i ];
   855 
   859 
   856 			//We ignore calculating positions of all connected containers when we're not over them
   860 			//We ignore calculating positions of all connected containers when we're not over them
   857 			if ( this.currentContainer && item.instance !== this.currentContainer &&
   861 			if ( this.currentContainer && item.instance !== this.currentContainer &&
   858 				item.item[ 0 ] !== this.currentItem[ 0 ] ) {
   862 					item.item[ 0 ] !== this.currentItem[ 0 ] ) {
   859 				continue;
   863 				continue;
   860 			}
   864 			}
   861 
   865 
   862 			t = this.options.toleranceElement ?
   866 			t = this.options.toleranceElement ?
   863 				$( this.options.toleranceElement, item.item ) :
   867 				$( this.options.toleranceElement, item.item ) :
   920 				element: function() {
   924 				element: function() {
   921 
   925 
   922 					var element = $( "<" + nodeName + ">", that.document[ 0 ] );
   926 					var element = $( "<" + nodeName + ">", that.document[ 0 ] );
   923 
   927 
   924 					that._addClass( element, "ui-sortable-placeholder",
   928 					that._addClass( element, "ui-sortable-placeholder",
   925 						className || that.currentItem[ 0 ].className )
   929 							className || that.currentItem[ 0 ].className )
   926 						._removeClass( element, "ui-sortable-helper" );
   930 						._removeClass( element, "ui-sortable-helper" );
   927 
   931 
   928 					if ( nodeName === "tbody" ) {
   932 					if ( nodeName === "tbody" ) {
   929 						that._createTrPlaceholder(
   933 						that._createTrPlaceholder(
   930 							that.currentItem.find( "tr" ).eq( 0 ),
   934 							that.currentItem.find( "tr" ).eq( 0 ),
   958 					// anyway since we're populating them with <td>s above, but they're unlikely to
   962 					// anyway since we're populating them with <td>s above, but they're unlikely to
   959 					// be the correct height on their own if the row heights are dynamic, so we'll
   963 					// be the correct height on their own if the row heights are dynamic, so we'll
   960 					// always assign the height of the dragged item given forcePlaceholderSize
   964 					// always assign the height of the dragged item given forcePlaceholderSize
   961 					// is true.
   965 					// is true.
   962 					if ( !p.height() || ( o.forcePlaceholderSize &&
   966 					if ( !p.height() || ( o.forcePlaceholderSize &&
   963 						( nodeName === "tbody" || nodeName === "tr" ) ) ) {
   967 							( nodeName === "tbody" || nodeName === "tr" ) ) ) {
   964 						p.height(
   968 						p.height(
   965 							that.currentItem.innerHeight() -
   969 							that.currentItem.innerHeight() -
   966 							parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) -
   970 							parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) -
   967 							parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) );
   971 							parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) );
   968 					}
   972 					}
  1013 
  1017 
  1014 			if ( this._intersectsWith( this.containers[ i ].containerCache ) ) {
  1018 			if ( this._intersectsWith( this.containers[ i ].containerCache ) ) {
  1015 
  1019 
  1016 				// If we've already found a container and it's more "inner" than this, then continue
  1020 				// If we've already found a container and it's more "inner" than this, then continue
  1017 				if ( innermostContainer &&
  1021 				if ( innermostContainer &&
  1018 					$.contains(
  1022 						$.contains(
  1019 						this.containers[ i ].element[ 0 ],
  1023 							this.containers[ i ].element[ 0 ],
  1020 						innermostContainer.element[ 0 ] ) ) {
  1024 							innermostContainer.element[ 0 ] ) ) {
  1021 					continue;
  1025 					continue;
  1022 				}
  1026 				}
  1023 
  1027 
  1024 				innermostContainer = this.containers[ i ];
  1028 				innermostContainer = this.containers[ i ];
  1025 				innermostIndex = i;
  1029 				innermostIndex = i;
  1057 			sizeProperty = floating ? "width" : "height";
  1061 			sizeProperty = floating ? "width" : "height";
  1058 			axis = floating ? "pageX" : "pageY";
  1062 			axis = floating ? "pageX" : "pageY";
  1059 
  1063 
  1060 			for ( j = this.items.length - 1; j >= 0; j-- ) {
  1064 			for ( j = this.items.length - 1; j >= 0; j-- ) {
  1061 				if ( !$.contains(
  1065 				if ( !$.contains(
  1062 					this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] )
  1066 						this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] )
  1063 				) {
  1067 				) {
  1064 					continue;
  1068 					continue;
  1065 				}
  1069 				}
  1066 				if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) {
  1070 				if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) {
  1067 					continue;
  1071 					continue;
  1108 			//Update scrollParent
  1112 			//Update scrollParent
  1109 			this.scrollParent = this.placeholder.scrollParent();
  1113 			this.scrollParent = this.placeholder.scrollParent();
  1110 
  1114 
  1111 			//Update overflowOffset
  1115 			//Update overflowOffset
  1112 			if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  1116 			if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  1113 				this.scrollParent[ 0 ].tagName !== "HTML" ) {
  1117 					this.scrollParent[ 0 ].tagName !== "HTML" ) {
  1114 				this.overflowOffset = this.scrollParent.offset();
  1118 				this.overflowOffset = this.scrollParent.offset();
  1115 			}
  1119 			}
  1116 
  1120 
  1117 			this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  1121 			this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  1118 			this.containers[ innermostIndex ].containerCache.over = 1;
  1122 			this.containers[ innermostIndex ].containerCache.over = 1;
  1186 		// next positioned parent
  1190 		// next positioned parent
  1187 		// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  1191 		// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  1188 		// the document, which means that the scroll is included in the initial calculation of the
  1192 		// the document, which means that the scroll is included in the initial calculation of the
  1189 		// offset of the parent, and never recalculated upon drag
  1193 		// offset of the parent, and never recalculated upon drag
  1190 		if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  1194 		if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  1191 			$.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  1195 				$.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  1192 			po.left += this.scrollParent.scrollLeft();
  1196 			po.left += this.scrollParent.scrollLeft();
  1193 			po.top += this.scrollParent.scrollTop();
  1197 			po.top += this.scrollParent.scrollTop();
  1194 		}
  1198 		}
  1195 
  1199 
  1196 		// This needs to be actually done for all browsers, since pageX/pageY includes this
  1200 		// This needs to be actually done for all browsers, since pageX/pageY includes this
  1197 		// information with an ugly IE fix
  1201 		// information with an ugly IE fix
  1198 		if ( this.offsetParent[ 0 ] === this.document[ 0 ].body ||
  1202 		if ( this.offsetParent[ 0 ] === this.document[ 0 ].body ||
  1199 			( this.offsetParent[ 0 ].tagName &&
  1203 				( this.offsetParent[ 0 ].tagName &&
  1200 				this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) {
  1204 				this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) {
  1201 			po = { top: 0, left: 0 };
  1205 			po = { top: 0, left: 0 };
  1202 		}
  1206 		}
  1203 
  1207 
  1204 		return {
  1208 		return {
  1251 				0 - this.offset.relative.top - this.offset.parent.top,
  1255 				0 - this.offset.relative.top - this.offset.parent.top,
  1252 				o.containment === "document" ?
  1256 				o.containment === "document" ?
  1253 					this.document.width() :
  1257 					this.document.width() :
  1254 					this.window.width() - this.helperProportions.width - this.margins.left,
  1258 					this.window.width() - this.helperProportions.width - this.margins.left,
  1255 				( o.containment === "document" ?
  1259 				( o.containment === "document" ?
  1256 						( this.document.height() || document.body.parentNode.scrollHeight ) :
  1260 					( this.document.height() || document.body.parentNode.scrollHeight ) :
  1257 						this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight
  1261 					this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight
  1258 				) - this.helperProportions.height - this.margins.top
  1262 				) - this.helperProportions.height - this.margins.top
  1259 			];
  1263 			];
  1260 		}
  1264 		}
  1261 
  1265 
  1262 		if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) {
  1266 		if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) {
  1264 			co = $( o.containment ).offset();
  1268 			co = $( o.containment ).offset();
  1265 			over = ( $( ce ).css( "overflow" ) !== "hidden" );
  1269 			over = ( $( ce ).css( "overflow" ) !== "hidden" );
  1266 
  1270 
  1267 			this.containment = [
  1271 			this.containment = [
  1268 				co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) +
  1272 				co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) +
  1269 				( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left,
  1273 					( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left,
  1270 				co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) +
  1274 				co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) +
  1271 				( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top,
  1275 					( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top,
  1272 				co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  1276 				co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  1273 				( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) -
  1277 					( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) -
  1274 				( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) -
  1278 					( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) -
  1275 				this.helperProportions.width - this.margins.left,
  1279 					this.helperProportions.width - this.margins.left,
  1276 				co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  1280 				co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  1277 				( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) -
  1281 					( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) -
  1278 				( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) -
  1282 					( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) -
  1279 				this.helperProportions.height - this.margins.top
  1283 					this.helperProportions.height - this.margins.top
  1280 			];
  1284 			];
  1281 		}
  1285 		}
  1282 
  1286 
  1283 	},
  1287 	},
  1284 
  1288 
  1287 		if ( !pos ) {
  1291 		if ( !pos ) {
  1288 			pos = this.position;
  1292 			pos = this.position;
  1289 		}
  1293 		}
  1290 		var mod = d === "absolute" ? 1 : -1,
  1294 		var mod = d === "absolute" ? 1 : -1,
  1291 			scroll = this.cssPosition === "absolute" &&
  1295 			scroll = this.cssPosition === "absolute" &&
  1292 			!( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  1296 				!( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  1293 				$.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  1297 				$.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  1294 				this.offsetParent :
  1298 					this.offsetParent :
  1295 				this.scrollParent,
  1299 					this.scrollParent,
  1296 			scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  1300 			scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  1297 
  1301 
  1298 		return {
  1302 		return {
  1299 			top: (
  1303 			top: (
  1300 
  1304 
  1320 
  1324 
  1321 				// The offsetParent's offset without borders (offset + border)
  1325 				// The offsetParent's offset without borders (offset + border)
  1322 				this.offset.parent.left * mod	-
  1326 				this.offset.parent.left * mod	-
  1323 				( ( this.cssPosition === "fixed" ?
  1327 				( ( this.cssPosition === "fixed" ?
  1324 					-this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 :
  1328 					-this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 :
  1325 						scroll.scrollLeft() ) * mod )
  1329 					scroll.scrollLeft() ) * mod )
  1326 			)
  1330 			)
  1327 		};
  1331 		};
  1328 
  1332 
  1329 	},
  1333 	},
  1330 
  1334 
  1333 		var top, left,
  1337 		var top, left,
  1334 			o = this.options,
  1338 			o = this.options,
  1335 			pageX = event.pageX,
  1339 			pageX = event.pageX,
  1336 			pageY = event.pageY,
  1340 			pageY = event.pageY,
  1337 			scroll = this.cssPosition === "absolute" &&
  1341 			scroll = this.cssPosition === "absolute" &&
  1338 			!( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  1342 				!( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  1339 				$.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  1343 				$.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  1340 				this.offsetParent :
  1344 					this.offsetParent :
  1341 				this.scrollParent,
  1345 					this.scrollParent,
  1342 			scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  1346 				scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  1343 
  1347 
  1344 		// This is another very weird special case that only happens for relative elements:
  1348 		// This is another very weird special case that only happens for relative elements:
  1345 		// 1. If the css position is relative
  1349 		// 1. If the css position is relative
  1346 		// 2. and the scroll parent is the document or similar to the offset parent
  1350 		// 2. and the scroll parent is the document or similar to the offset parent
  1347 		// we have to refresh the relative offset during the scroll so there are no jumps
  1351 		// we have to refresh the relative offset during the scroll so there are no jumps
  1348 		if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  1352 		if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  1349 			this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) {
  1353 				this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) {
  1350 			this.offset.relative = this._getRelativeOffset();
  1354 			this.offset.relative = this._getRelativeOffset();
  1351 		}
  1355 		}
  1352 
  1356 
  1353 		/*
  1357 		/*
  1354 		 * - Position constraining -
  1358 		 * - Position constraining -
  1376 				top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) /
  1380 				top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) /
  1377 					o.grid[ 1 ] ) * o.grid[ 1 ];
  1381 					o.grid[ 1 ] ) * o.grid[ 1 ];
  1378 				pageY = this.containment ?
  1382 				pageY = this.containment ?
  1379 					( ( top - this.offset.click.top >= this.containment[ 1 ] &&
  1383 					( ( top - this.offset.click.top >= this.containment[ 1 ] &&
  1380 						top - this.offset.click.top <= this.containment[ 3 ] ) ?
  1384 						top - this.offset.click.top <= this.containment[ 3 ] ) ?
  1381 						top :
  1385 							top :
  1382 						( ( top - this.offset.click.top >= this.containment[ 1 ] ) ?
  1386 							( ( top - this.offset.click.top >= this.containment[ 1 ] ) ?
  1383 							top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) :
  1387 								top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) :
  1384 					top;
  1388 								top;
  1385 
  1389 
  1386 				left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) /
  1390 				left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) /
  1387 					o.grid[ 0 ] ) * o.grid[ 0 ];
  1391 					o.grid[ 0 ] ) * o.grid[ 0 ];
  1388 				pageX = this.containment ?
  1392 				pageX = this.containment ?
  1389 					( ( left - this.offset.click.left >= this.containment[ 0 ] &&
  1393 					( ( left - this.offset.click.left >= this.containment[ 0 ] &&
  1390 						left - this.offset.click.left <= this.containment[ 2 ] ) ?
  1394 						left - this.offset.click.left <= this.containment[ 2 ] ) ?
  1391 						left :
  1395 							left :
  1392 						( ( left - this.offset.click.left >= this.containment[ 0 ] ) ?
  1396 							( ( left - this.offset.click.left >= this.containment[ 0 ] ) ?
  1393 							left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) :
  1397 								left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) :
  1394 					left;
  1398 								left;
  1395 			}
  1399 			}
  1396 
  1400 
  1397 		}
  1401 		}
  1398 
  1402 
  1399 		return {
  1403 		return {
  1496 			delayedTriggers.push( function( event ) {
  1500 			delayedTriggers.push( function( event ) {
  1497 				this._trigger( "receive", event, this._uiHash( this.fromOutside ) );
  1501 				this._trigger( "receive", event, this._uiHash( this.fromOutside ) );
  1498 			} );
  1502 			} );
  1499 		}
  1503 		}
  1500 		if ( ( this.fromOutside ||
  1504 		if ( ( this.fromOutside ||
  1501 			this.domPosition.prev !==
  1505 				this.domPosition.prev !==
  1502 			this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] ||
  1506 				this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] ||
  1503 			this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) {
  1507 				this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) {
  1504 
  1508 
  1505 			// Trigger update callback if the DOM position has changed
  1509 			// Trigger update callback if the DOM position has changed
  1506 			delayedTriggers.push( function( event ) {
  1510 			delayedTriggers.push( function( event ) {
  1507 				this._trigger( "update", event, this._uiHash() );
  1511 				this._trigger( "update", event, this._uiHash() );
  1508 			} );
  1512 			} );