aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorAlexander Schmitz <arschmitz@gmail.com>2015-08-24 08:59:44 -0400
committerAlexander Schmitz <arschmitz@gmail.com>2015-09-11 08:29:09 -0400
commit8336ba7b694fbf85ec893ce79343a9f510a1e0b0 (patch)
tree19894ab900093e0291fecf27e1cfcadb8491e6b9 /ui
parent0cab9f0a2f1f91ae671d57dba5e5bdcde1f60622 (diff)
downloadjquery-ui-8336ba7b694fbf85ec893ce79343a9f510a1e0b0.tar.gz
jquery-ui-8336ba7b694fbf85ec893ce79343a9f510a1e0b0.zip
Draggable: Style updates
Ref #14246
Diffstat (limited to 'ui')
-rw-r--r--ui/widgets/draggable.js394
1 files changed, 201 insertions, 193 deletions
diff --git a/ui/widgets/draggable.js b/ui/widgets/draggable.js
index b2c56509f..fc340626e 100644
--- a/ui/widgets/draggable.js
+++ b/ui/widgets/draggable.js
@@ -14,11 +14,11 @@
//>>demos: http://jqueryui.com/draggable/
//>>css.structure: ../themes/base/draggable.css
-(function( factory ) {
+( function( factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
- define([
+ define( [
"jquery",
"./mouse",
"../data",
@@ -34,9 +34,9 @@
// Browser globals
factory( jQuery );
}
-}(function( $ ) {
+}( function( $ ) {
-$.widget("ui.draggable", $.ui.mouse, {
+$.widget( "ui.draggable", $.ui.mouse, {
version: "@VERSION",
widgetEventPrefix: "drag",
options: {
@@ -75,10 +75,10 @@ $.widget("ui.draggable", $.ui.mouse, {
if ( this.options.helper === "original" ) {
this._setPositionRelative();
}
- if (this.options.addClasses){
+ if ( this.options.addClasses ) {
this._addClass( "ui-draggable" );
}
- if (this.options.disabled){
+ if ( this.options.disabled ) {
this._addClass( "ui-draggable-disabled" );
}
this._setHandleClassName();
@@ -103,19 +103,19 @@ $.widget("ui.draggable", $.ui.mouse, {
this._mouseDestroy();
},
- _mouseCapture: function(event) {
+ _mouseCapture: function( event ) {
var o = this.options;
this._blurActiveElement( event );
// Among others, prevent a drag on a resizable-handle
- if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
+ if ( this.helper || o.disabled || $( event.target ).closest( ".ui-resizable-handle" ).length > 0 ) {
return false;
}
//Quit if we're not on a valid handle
- this.handle = this._getHandle(event);
- if (!this.handle) {
+ this.handle = this._getHandle( event );
+ if ( !this.handle ) {
return false;
}
@@ -126,7 +126,7 @@ $.widget("ui.draggable", $.ui.mouse, {
},
_blockFrames: function( selector ) {
- this.iframeBlocks = this.document.find( selector ).map(function() {
+ this.iframeBlocks = this.document.find( selector ).map( function() {
var iframe = $( this );
return $( "<div>" )
@@ -135,7 +135,7 @@ $.widget("ui.draggable", $.ui.mouse, {
.outerWidth( iframe.outerWidth() )
.outerHeight( iframe.outerHeight() )
.offset( iframe.offset() )[ 0 ];
- });
+ } );
},
_unblockFrames: function() {
@@ -156,12 +156,12 @@ $.widget("ui.draggable", $.ui.mouse, {
$.ui.safeBlur( $.ui.safeActiveElement( this.document[ 0 ] ) );
},
- _mouseStart: function(event) {
+ _mouseStart: function( event ) {
var o = this.options;
//Create and append the visible helper
- this.helper = this._createHelper(event);
+ this.helper = this._createHelper( event );
this._addClass( this.helper, "ui-draggable-dragging" );
@@ -169,7 +169,7 @@ $.widget("ui.draggable", $.ui.mouse, {
this._cacheHelperProportions();
//If ddmanager is used for droppables, set the global draggable
- if ($.ui.ddmanager) {
+ if ( $.ui.ddmanager ) {
$.ui.ddmanager.current = this;
}
@@ -185,9 +185,9 @@ $.widget("ui.draggable", $.ui.mouse, {
this.cssPosition = this.helper.css( "position" );
this.scrollParent = this.helper.scrollParent( true );
this.offsetParent = this.helper.offsetParent();
- this.hasFixedAncestor = this.helper.parents().filter(function() {
+ this.hasFixedAncestor = this.helper.parents().filter( function() {
return $( this ).css( "position" ) === "fixed";
- }).length > 0;
+ } ).length > 0;
//The element's absolute position on the page minus margins
this.positionAbs = this.element.offset();
@@ -199,13 +199,13 @@ $.widget("ui.draggable", $.ui.mouse, {
this.originalPageY = event.pageY;
//Adjust the mouse offset relative to the helper if "cursorAt" is supplied
- (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
+ ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
//Set a containment if given in the options
this._setContainment();
//Trigger event + callbacks
- if (this._trigger("start", event) === false) {
+ if ( this._trigger( "start", event ) === false ) {
this._clear();
return false;
}
@@ -214,15 +214,15 @@ $.widget("ui.draggable", $.ui.mouse, {
this._cacheHelperProportions();
//Prepare the droppable offsets
- if ($.ui.ddmanager && !o.dropBehaviour) {
- $.ui.ddmanager.prepareOffsets(this, event);
+ if ( $.ui.ddmanager && !o.dropBehaviour ) {
+ $.ui.ddmanager.prepareOffsets( this, event );
}
- this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
+ this._mouseDrag( event, true ); //Execute the drag once - this causes the helper not to be visible before getting its correct position
//If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
if ( $.ui.ddmanager ) {
- $.ui.ddmanager.dragStart(this, event);
+ $.ui.ddmanager.dragStart( this, event );
}
return true;
@@ -243,7 +243,8 @@ $.widget("ui.draggable", $.ui.mouse, {
};
},
- _mouseDrag: function(event, noPropagation) {
+ _mouseDrag: function( event, noPropagation ) {
+
// reset any necessary cached properties (see #5009)
if ( this.hasFixedAncestor ) {
this.offset.parent = this._getParentOffset();
@@ -251,13 +252,13 @@ $.widget("ui.draggable", $.ui.mouse, {
//Compute the helpers position
this.position = this._generatePosition( event, true );
- this.positionAbs = this._convertPositionTo("absolute");
+ this.positionAbs = this._convertPositionTo( "absolute" );
//Call plugins and callbacks and use the resulting position if something is returned
- if (!noPropagation) {
+ if ( !noPropagation ) {
var ui = this._uiHash();
- if (this._trigger("drag", event, ui) === false) {
- this._mouseUp({});
+ if ( this._trigger( "drag", event, ui ) === false ) {
+ this._mouseUp( {} );
return false;
}
this.position = ui.position;
@@ -266,36 +267,36 @@ $.widget("ui.draggable", $.ui.mouse, {
this.helper[ 0 ].style.left = this.position.left + "px";
this.helper[ 0 ].style.top = this.position.top + "px";
- if ($.ui.ddmanager) {
- $.ui.ddmanager.drag(this, event);
+ if ( $.ui.ddmanager ) {
+ $.ui.ddmanager.drag( this, event );
}
return false;
},
- _mouseStop: function(event) {
+ _mouseStop: function( event ) {
//If we are using droppables, inform the manager about the drop
var that = this,
dropped = false;
- if ($.ui.ddmanager && !this.options.dropBehaviour) {
- dropped = $.ui.ddmanager.drop(this, event);
+ if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
+ dropped = $.ui.ddmanager.drop( this, event );
}
//if a drop comes from outside (a sortable)
- if (this.dropped) {
+ if ( this.dropped ) {
dropped = this.dropped;
this.dropped = false;
}
- if ((this.options.revert === "invalid" && !dropped) || (this.options.revert === "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
- $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
- if (that._trigger("stop", event) !== false) {
+ if ( ( this.options.revert === "invalid" && !dropped ) || ( this.options.revert === "valid" && dropped ) || this.options.revert === true || ( $.isFunction( this.options.revert ) && this.options.revert.call( this.element, dropped ) ) ) {
+ $( this.helper ).animate( this.originalPosition, parseInt( this.options.revertDuration, 10 ), function() {
+ if ( that._trigger( "stop", event ) !== false ) {
that._clear();
}
- });
+ } );
} else {
- if (this._trigger("stop", event) !== false) {
+ if ( this._trigger( "stop", event ) !== false ) {
this._clear();
}
}
@@ -308,22 +309,23 @@ $.widget("ui.draggable", $.ui.mouse, {
//If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
if ( $.ui.ddmanager ) {
- $.ui.ddmanager.dragStop(this, event);
+ $.ui.ddmanager.dragStop( this, event );
}
// Only need to focus if the event occurred on the draggable itself, see #10527
if ( this.handleElement.is( event.target ) ) {
+
// The interaction is over; whether or not the click resulted in a drag, focus the element
this.element.trigger( "focus" );
}
- return $.ui.mouse.prototype._mouseUp.call(this, event);
+ return $.ui.mouse.prototype._mouseUp.call( this, event );
},
cancel: function() {
- if (this.helper.is(".ui-draggable-dragging")) {
- this._mouseUp({});
+ if ( this.helper.is( ".ui-draggable-dragging" ) ) {
+ this._mouseUp( {} );
} else {
this._clear();
}
@@ -332,7 +334,7 @@ $.widget("ui.draggable", $.ui.mouse, {
},
- _getHandle: function(event) {
+ _getHandle: function( event ) {
return this.options.handle ?
!!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
true;
@@ -348,7 +350,7 @@ $.widget("ui.draggable", $.ui.mouse, {
this._removeClass( this.handleElement, "ui-draggable-handle" );
},
- _createHelper: function(event) {
+ _createHelper: function( event ) {
var o = this.options,
helperIsFunction = $.isFunction( o.helper ),
@@ -358,8 +360,8 @@ $.widget("ui.draggable", $.ui.mouse, {
this.element.clone().removeAttr( "id" ) :
this.element );
- if (!helper.parents("body").length) {
- helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
+ if ( !helper.parents( "body" ).length ) {
+ helper.appendTo( ( o.appendTo === "parent" ? this.element[ 0 ].parentNode : o.appendTo ) );
}
// Http://bugs.jqueryui.com/ticket/9446
@@ -369,8 +371,8 @@ $.widget("ui.draggable", $.ui.mouse, {
this._setPositionRelative();
}
- if (helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
- helper.css("position", "absolute");
+ if ( helper[ 0 ] !== this.element[ 0 ] && !( /(fixed|absolute)/ ).test( helper.css( "position" ) ) ) {
+ helper.css( "position", "absolute" );
}
return helper;
@@ -383,23 +385,23 @@ $.widget("ui.draggable", $.ui.mouse, {
}
},
- _adjustOffsetFromHelper: function(obj) {
- if (typeof obj === "string") {
- obj = obj.split(" ");
+ _adjustOffsetFromHelper: function( obj ) {
+ if ( typeof obj === "string" ) {
+ obj = obj.split( " " );
}
- if ($.isArray(obj)) {
- obj = { left: +obj[0], top: +obj[1] || 0 };
+ if ( $.isArray( obj ) ) {
+ obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
}
- if ("left" in obj) {
+ if ( "left" in obj ) {
this.offset.click.left = obj.left + this.margins.left;
}
- if ("right" in obj) {
+ if ( "right" in obj ) {
this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
}
- if ("top" in obj) {
+ if ( "top" in obj ) {
this.offset.click.top = obj.top + this.margins.top;
}
- if ("bottom" in obj) {
+ if ( "bottom" in obj ) {
this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
}
},
@@ -418,7 +420,7 @@ $.widget("ui.draggable", $.ui.mouse, {
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
- if (this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
+ if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
po.left += this.scrollParent.scrollLeft();
po.top += this.scrollParent.scrollTop();
}
@@ -428,8 +430,8 @@ $.widget("ui.draggable", $.ui.mouse, {
}
return {
- top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),
- left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)
+ top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
+ left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
};
},
@@ -443,18 +445,18 @@ $.widget("ui.draggable", $.ui.mouse, {
scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
return {
- top: p.top - ( parseInt(this.helper.css( "top" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
- left: p.left - ( parseInt(this.helper.css( "left" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
+ top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
+ left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
};
},
_cacheMargins: function() {
this.margins = {
- left: (parseInt(this.element.css("marginLeft"), 10) || 0),
- top: (parseInt(this.element.css("marginTop"), 10) || 0),
- right: (parseInt(this.element.css("marginRight"), 10) || 0),
- bottom: (parseInt(this.element.css("marginBottom"), 10) || 0)
+ left: ( parseInt( this.element.css( "marginLeft" ), 10 ) || 0 ),
+ top: ( parseInt( this.element.css( "marginTop" ), 10 ) || 0 ),
+ right: ( parseInt( this.element.css( "marginRight" ), 10 ) || 0 ),
+ bottom: ( parseInt( this.element.css( "marginBottom" ), 10 ) || 0 )
};
},
@@ -488,7 +490,7 @@ $.widget("ui.draggable", $.ui.mouse, {
return;
}
- if ( o.containment === "document") {
+ if ( o.containment === "document" ) {
this.containment = [
0,
0,
@@ -535,9 +537,9 @@ $.widget("ui.draggable", $.ui.mouse, {
this.relativeContainer = c;
},
- _convertPositionTo: function(d, pos) {
+ _convertPositionTo: function( d, pos ) {
- if (!pos) {
+ if ( !pos ) {
pos = this.position;
}
@@ -549,13 +551,13 @@ $.widget("ui.draggable", $.ui.mouse, {
pos.top + // The absolute mouse position
this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
- ( ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod)
+ ( ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod )
),
left: (
pos.left + // The absolute mouse position
this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
- ( ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod)
+ ( ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod )
)
};
@@ -585,7 +587,7 @@ $.widget("ui.draggable", $.ui.mouse, {
// If we are not dragging yet, we won't check for options
if ( constrainPosition ) {
if ( this.containment ) {
- if ( this.relativeContainer ){
+ if ( this.relativeContainer ) {
co = this.relativeContainer.offset();
containment = [
this.containment[ 0 ] + co.left,
@@ -597,27 +599,28 @@ $.widget("ui.draggable", $.ui.mouse, {
containment = this.containment;
}
- if (event.pageX - this.offset.click.left < containment[0]) {
- pageX = containment[0] + this.offset.click.left;
+ if ( event.pageX - this.offset.click.left < containment[ 0 ] ) {
+ pageX = containment[ 0 ] + this.offset.click.left;
}
- if (event.pageY - this.offset.click.top < containment[1]) {
- pageY = containment[1] + this.offset.click.top;
+ if ( event.pageY - this.offset.click.top < containment[ 1 ] ) {
+ pageY = containment[ 1 ] + this.offset.click.top;
}
- if (event.pageX - this.offset.click.left > containment[2]) {
- pageX = containment[2] + this.offset.click.left;
+ if ( event.pageX - this.offset.click.left > containment[ 2 ] ) {
+ pageX = containment[ 2 ] + this.offset.click.left;
}
- if (event.pageY - this.offset.click.top > containment[3]) {
- pageY = containment[3] + this.offset.click.top;
+ if ( event.pageY - this.offset.click.top > containment[ 3 ] ) {
+ pageY = containment[ 3 ] + this.offset.click.top;
}
}
- if (o.grid) {
+ if ( o.grid ) {
+
//Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
- top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
- pageY = containment ? ((top - this.offset.click.top >= containment[1] || top - this.offset.click.top > containment[3]) ? top : ((top - this.offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
+ top = o.grid[ 1 ] ? this.originalPageY + Math.round( ( pageY - this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ] : this.originalPageY;
+ pageY = containment ? ( ( top - this.offset.click.top >= containment[ 1 ] || top - this.offset.click.top > containment[ 3 ] ) ? top : ( ( top - this.offset.click.top >= containment[ 1 ] ) ? top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top;
- left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
- pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
+ left = o.grid[ 0 ] ? this.originalPageX + Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ] : this.originalPageX;
+ pageX = containment ? ( ( left - this.offset.click.left >= containment[ 0 ] || left - this.offset.click.left > containment[ 2 ] ) ? left : ( ( left - this.offset.click.left >= containment[ 0 ] ) ? left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left;
}
if ( o.axis === "y" ) {
@@ -650,7 +653,7 @@ $.widget("ui.draggable", $.ui.mouse, {
_clear: function() {
this._removeClass( this.helper, "ui-draggable-dragging" );
- if (this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
+ if ( this.helper[ 0 ] !== this.element[ 0 ] && !this.cancelHelperRemoval ) {
this.helper.remove();
}
this.helper = null;
@@ -685,16 +688,16 @@ $.widget("ui.draggable", $.ui.mouse, {
};
}
-});
+} );
$.ui.plugin.add( "draggable", "connectToSortable", {
start: function( event, ui, draggable ) {
var uiSortable = $.extend( {}, ui, {
item: draggable.element
- });
+ } );
draggable.sortables = [];
- $( draggable.options.connectToSortable ).each(function() {
+ $( draggable.options.connectToSortable ).each( function() {
var sortable = $( this ).sortable( "instance" );
if ( sortable && !sortable.options.disabled ) {
@@ -704,14 +707,14 @@ $.ui.plugin.add( "draggable", "connectToSortable", {
// which is used in drag. This ensures it's initialized and synchronized
// with any changes that might have happened on the page since initialization.
sortable.refreshPositions();
- sortable._trigger("activate", event, uiSortable);
+ sortable._trigger( "activate", event, uiSortable );
}
- });
+ } );
},
stop: function( event, ui, draggable ) {
var uiSortable = $.extend( {}, ui, {
item: draggable.element
- });
+ } );
draggable.cancelHelperRemoval = false;
@@ -734,12 +737,13 @@ $.ui.plugin.add( "draggable", "connectToSortable", {
left: sortable.placeholder.css( "left" )
};
- sortable._mouseStop(event);
+ sortable._mouseStop( event );
// Once drag has ended, the sortable should return to using
// its original helper, not the shared helper from draggable
sortable.options.helper = sortable.options._helper;
} else {
+
// Prevent this Sortable from removing the helper.
// However, don't set the draggable to remove the helper
// either as another connected Sortable may yet handle the removal.
@@ -747,7 +751,7 @@ $.ui.plugin.add( "draggable", "connectToSortable", {
sortable._trigger( "deactivate", event, uiSortable );
}
- });
+ } );
},
drag: function( event, ui, draggable ) {
$.each( draggable.sortables, function() {
@@ -763,6 +767,7 @@ $.ui.plugin.add( "draggable", "connectToSortable", {
innermostIntersecting = true;
$.each( draggable.sortables, function() {
+
// Copy over variables that sortable's _intersectsWith uses
this.positionAbs = draggable.positionAbs;
this.helperProportions = draggable.helperProportions;
@@ -775,10 +780,11 @@ $.ui.plugin.add( "draggable", "connectToSortable", {
}
return innermostIntersecting;
- });
+ } );
}
if ( innermostIntersecting ) {
+
// If it intersects, we use a little isOver variable and set it once,
// so that the move-in stuff gets fired only once.
if ( !sortable.isOver ) {
@@ -823,7 +829,7 @@ $.ui.plugin.add( "draggable", "connectToSortable", {
// adding to one sortable changes the location of the other sortables (#9675)
$.each( draggable.sortables, function() {
this.refreshPositions();
- });
+ } );
// Hack so receive/update callbacks work (mostly)
draggable.currentItem = draggable.element;
@@ -832,12 +838,14 @@ $.ui.plugin.add( "draggable", "connectToSortable", {
if ( sortable.currentItem ) {
sortable._mouseDrag( event );
+
// Copy the sortable's position because the draggable's can potentially reflect
// a relative position, while sortable is always absolute, which the dragged
// element has now become. (#8809)
ui.position = sortable.position;
}
} else {
+
// If it doesn't intersect with the sortable, and it intersected before,
// we fake the drag stop of the sortable, but make sure it doesn't remove
// the helper by using cancelHelperRemoval.
@@ -878,49 +886,49 @@ $.ui.plugin.add( "draggable", "connectToSortable", {
// from one sortable changes the location of other sortables (#9675)
$.each( draggable.sortables, function() {
this.refreshPositions();
- });
+ } );
}
}
- });
+ } );
}
-});
+} );
-$.ui.plugin.add("draggable", "cursor", {
+$.ui.plugin.add( "draggable", "cursor", {
start: function( event, ui, instance ) {
var t = $( "body" ),
o = instance.options;
- if (t.css("cursor")) {
- o._cursor = t.css("cursor");
+ if ( t.css( "cursor" ) ) {
+ o._cursor = t.css( "cursor" );
}
- t.css("cursor", o.cursor);
+ t.css( "cursor", o.cursor );
},
stop: function( event, ui, instance ) {
var o = instance.options;
- if (o._cursor) {
- $("body").css("cursor", o._cursor);
+ if ( o._cursor ) {
+ $( "body" ).css( "cursor", o._cursor );
}
}
-});
+} );
-$.ui.plugin.add("draggable", "opacity", {
+$.ui.plugin.add( "draggable", "opacity", {
start: function( event, ui, instance ) {
var t = $( ui.helper ),
o = instance.options;
- if (t.css("opacity")) {
- o._opacity = t.css("opacity");
+ if ( t.css( "opacity" ) ) {
+ o._opacity = t.css( "opacity" );
}
- t.css("opacity", o.opacity);
+ t.css( "opacity", o.opacity );
},
stop: function( event, ui, instance ) {
var o = instance.options;
- if (o._opacity) {
- $(ui.helper).css("opacity", o._opacity);
+ if ( o._opacity ) {
+ $( ui.helper ).css( "opacity", o._opacity );
}
}
-});
+} );
-$.ui.plugin.add("draggable", "scroll", {
+$.ui.plugin.add( "draggable", "scroll", {
start: function( event, ui, i ) {
if ( !i.scrollParentNotHidden ) {
i.scrollParentNotHidden = i.helper.scrollParent( false );
@@ -956,49 +964,49 @@ $.ui.plugin.add("draggable", "scroll", {
} else {
- if (!o.axis || o.axis !== "x") {
- if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
- scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
- } else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
- scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
+ if ( !o.axis || o.axis !== "x" ) {
+ if ( event.pageY - $( document ).scrollTop() < o.scrollSensitivity ) {
+ scrolled = $( document ).scrollTop( $( document ).scrollTop() - o.scrollSpeed );
+ } else if ( $( window ).height() - ( event.pageY - $( document ).scrollTop() ) < o.scrollSensitivity ) {
+ scrolled = $( document ).scrollTop( $( document ).scrollTop() + o.scrollSpeed );
}
}
- if (!o.axis || o.axis !== "y") {
- if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
- scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
- } else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
- scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
+ if ( !o.axis || o.axis !== "y" ) {
+ if ( event.pageX - $( document ).scrollLeft() < o.scrollSensitivity ) {
+ scrolled = $( document ).scrollLeft( $( document ).scrollLeft() - o.scrollSpeed );
+ } else if ( $( window ).width() - ( event.pageX - $( document ).scrollLeft() ) < o.scrollSensitivity ) {
+ scrolled = $( document ).scrollLeft( $( document ).scrollLeft() + o.scrollSpeed );
}
}
}
- if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
- $.ui.ddmanager.prepareOffsets(i, event);
+ if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
+ $.ui.ddmanager.prepareOffsets( i, event );
}
}
-});
+} );
-$.ui.plugin.add("draggable", "snap", {
+$.ui.plugin.add( "draggable", "snap", {
start: function( event, ui, i ) {
var o = i.options;
i.snapElements = [];
- $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
- var $t = $(this),
+ $( o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap ).each( function() {
+ var $t = $( this ),
$o = $t.offset();
- if (this !== i.element[0]) {
- i.snapElements.push({
+ if ( this !== i.element[ 0 ] ) {
+ i.snapElements.push( {
item: this,
width: $t.outerWidth(), height: $t.outerHeight(),
top: $o.top, left: $o.left
- });
+ } );
}
- });
+ } );
},
drag: function( event, ui, inst ) {
@@ -1009,108 +1017,108 @@ $.ui.plugin.add("draggable", "snap", {
x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
- for (i = inst.snapElements.length - 1; i >= 0; i--){
+ for ( i = inst.snapElements.length - 1; i >= 0; i-- ) {
- l = inst.snapElements[i].left - inst.margins.left;
- r = l + inst.snapElements[i].width;
- t = inst.snapElements[i].top - inst.margins.top;
- b = t + inst.snapElements[i].height;
+ l = inst.snapElements[ i ].left - inst.margins.left;
+ r = l + inst.snapElements[ i ].width;
+ t = inst.snapElements[ i ].top - inst.margins.top;
+ b = t + inst.snapElements[ i ].height;
if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
- if (inst.snapElements[i].snapping) {
- (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
+ if ( inst.snapElements[ i ].snapping ) {
+ ( inst.options.snap.release && inst.options.snap.release.call( inst.element, event, $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } ) ) );
}
- inst.snapElements[i].snapping = false;
+ inst.snapElements[ i ].snapping = false;
continue;
}
- if (o.snapMode !== "inner") {
- ts = Math.abs(t - y2) <= d;
- bs = Math.abs(b - y1) <= d;
- ls = Math.abs(l - x2) <= d;
- rs = Math.abs(r - x1) <= d;
- if (ts) {
- ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;
+ if ( o.snapMode !== "inner" ) {
+ ts = Math.abs( t - y2 ) <= d;
+ bs = Math.abs( b - y1 ) <= d;
+ ls = Math.abs( l - x2 ) <= d;
+ rs = Math.abs( r - x1 ) <= d;
+ if ( ts ) {
+ ui.position.top = inst._convertPositionTo( "relative", { top: t - inst.helperProportions.height, left: 0 } ).top;
}
- if (bs) {
- ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top;
+ if ( bs ) {
+ ui.position.top = inst._convertPositionTo( "relative", { top: b, left: 0 } ).top;
}
- if (ls) {
- ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;
+ if ( ls ) {
+ ui.position.left = inst._convertPositionTo( "relative", { top: 0, left: l - inst.helperProportions.width } ).left;
}
- if (rs) {
- ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left;
+ if ( rs ) {
+ ui.position.left = inst._convertPositionTo( "relative", { top: 0, left: r } ).left;
}
}
- first = (ts || bs || ls || rs);
+ first = ( ts || bs || ls || rs );
- if (o.snapMode !== "outer") {
- ts = Math.abs(t - y1) <= d;
- bs = Math.abs(b - y2) <= d;
- ls = Math.abs(l - x1) <= d;
- rs = Math.abs(r - x2) <= d;
- if (ts) {
- ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top;
+ if ( o.snapMode !== "outer" ) {
+ ts = Math.abs( t - y1 ) <= d;
+ bs = Math.abs( b - y2 ) <= d;
+ ls = Math.abs( l - x1 ) <= d;
+ rs = Math.abs( r - x2 ) <= d;
+ if ( ts ) {
+ ui.position.top = inst._convertPositionTo( "relative", { top: t, left: 0 } ).top;
}
- if (bs) {
- ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;
+ if ( bs ) {
+ ui.position.top = inst._convertPositionTo( "relative", { top: b - inst.helperProportions.height, left: 0 } ).top;
}
- if (ls) {
- ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left;
+ if ( ls ) {
+ ui.position.left = inst._convertPositionTo( "relative", { top: 0, left: l } ).left;
}
- if (rs) {
- ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;
+ if ( rs ) {
+ ui.position.left = inst._convertPositionTo( "relative", { top: 0, left: r - inst.helperProportions.width } ).left;
}
}
- if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
- (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
+ if ( !inst.snapElements[ i ].snapping && ( ts || bs || ls || rs || first ) ) {
+ ( inst.options.snap.snap && inst.options.snap.snap.call( inst.element, event, $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } ) ) );
}
- inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
+ inst.snapElements[ i ].snapping = ( ts || bs || ls || rs || first );
}
}
-});
+} );
-$.ui.plugin.add("draggable", "stack", {
+$.ui.plugin.add( "draggable", "stack", {
start: function( event, ui, instance ) {
var min,
o = instance.options,
- group = $.makeArray($(o.stack)).sort(function(a, b) {
- return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0);
- });
+ group = $.makeArray( $( o.stack ) ).sort( function( a, b ) {
+ return ( parseInt( $( a ).css( "zIndex" ), 10 ) || 0 ) - ( parseInt( $( b ).css( "zIndex" ), 10 ) || 0 );
+ } );
- if (!group.length) { return; }
+ if ( !group.length ) { return; }
- min = parseInt($(group[0]).css("zIndex"), 10) || 0;
- $(group).each(function(i) {
- $(this).css("zIndex", min + i);
- });
- this.css("zIndex", (min + group.length));
+ min = parseInt( $( group[ 0 ] ).css( "zIndex" ), 10 ) || 0;
+ $( group ).each( function( i ) {
+ $( this ).css( "zIndex", min + i );
+ } );
+ this.css( "zIndex", ( min + group.length ) );
}
-});
+} );
-$.ui.plugin.add("draggable", "zIndex", {
+$.ui.plugin.add( "draggable", "zIndex", {
start: function( event, ui, instance ) {
var t = $( ui.helper ),
o = instance.options;
- if (t.css("zIndex")) {
- o._zIndex = t.css("zIndex");
+ if ( t.css( "zIndex" ) ) {
+ o._zIndex = t.css( "zIndex" );
}
- t.css("zIndex", o.zIndex);
+ t.css( "zIndex", o.zIndex );
},
stop: function( event, ui, instance ) {
var o = instance.options;
- if (o._zIndex) {
- $(ui.helper).css("zIndex", o._zIndex);
+ if ( o._zIndex ) {
+ $( ui.helper ).css( "zIndex", o._zIndex );
}
}
-});
+} );
return $.ui.draggable;
-}));
+} ) );