},
_destroy: function() {
+ if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
+ this.destroyOnClear = true;
+ return;
+ }
this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
this._mouseDestroy();
},
this.dropped = false;
}
- //if the original element is no longer in the DOM don't bother to continue (see #8269)
- if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) {
- return 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) {
}
this.helper = null;
this.cancelHelperRemoval = false;
+ if ( this.destroyOnClear ) {
+ this.destroy();
+ }
},
// From now on bulk stuff - mainly helpers
_trigger: function(type, event, ui) {
ui = ui || this._uiHash();
- $.ui.plugin.call(this, type, [event, ui]);
+ $.ui.plugin.call( this, type, [ event, ui, this ], true );
//The absolute position has to be recalculated after plugins
if(type === "drag") {
this.positionAbs = this._convertPositionTo("absolute");
});
$.ui.plugin.add("draggable", "connectToSortable", {
- start: function(event, ui) {
+ start: function( event, ui, inst ) {
- var inst = $(this).draggable( "instance" ), o = inst.options,
+ var o = inst.options,
uiSortable = $.extend({}, ui, { item: inst.element });
inst.sortables = [];
$(o.connectToSortable).each(function() {
});
},
- stop: function(event, ui) {
+ stop: function( event, ui, inst ) {
//If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
- var inst = $(this).draggable( "instance" ),
- uiSortable = $.extend({}, ui, { item: inst.element });
+ var uiSortable = $.extend( {}, ui, {
+ item: inst.element
+ });
$.each(inst.sortables, function() {
if(this.instance.isOver) {
});
},
- drag: function(event, ui) {
+ drag: function( event, ui, inst ) {
- var inst = $(this).draggable( "instance" ), that = this;
+ var that = this;
$.each(inst.sortables, function() {
});
$.ui.plugin.add("draggable", "cursor", {
- start: function() {
- var t = $("body"), o = $(this).draggable( "instance" ).options;
+ start: function( event, ui, instance ) {
+ var t = $( "body" ),
+ o = instance.options;
+
if (t.css("cursor")) {
o._cursor = t.css("cursor");
}
t.css("cursor", o.cursor);
},
- stop: function() {
- var o = $(this).draggable( "instance" ).options;
+ stop: function( event, ui, instance ) {
+ var o = instance.options;
if (o._cursor) {
$("body").css("cursor", o._cursor);
}
});
$.ui.plugin.add("draggable", "opacity", {
- start: function(event, ui) {
- var t = $(ui.helper), o = $(this).draggable( "instance" ).options;
+ start: function( event, ui, instance ) {
+ var t = $( ui.helper ),
+ o = instance.options;
if(t.css("opacity")) {
o._opacity = t.css("opacity");
}
t.css("opacity", o.opacity);
},
- stop: function(event, ui) {
- var o = $(this).draggable( "instance" ).options;
+ stop: function( event, ui, instance ) {
+ var o = instance.options;
if(o._opacity) {
$(ui.helper).css("opacity", o._opacity);
}
});
$.ui.plugin.add("draggable", "scroll", {
- start: function() {
- var i = $(this).draggable( "instance" );
+ start: function( event, ui, i ) {
if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
i.overflowOffset = i.scrollParent.offset();
}
},
- drag: function( event ) {
+ drag: function( event, ui, i ) {
- var i = $(this).draggable( "instance" ), o = i.options, scrolled = false;
+ var o = i.options,
+ scrolled = false;
if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
});
$.ui.plugin.add("draggable", "snap", {
- start: function() {
+ start: function( event, ui, i ) {
- var i = $(this).draggable( "instance" ),
- o = i.options;
+ var o = i.options;
i.snapElements = [];
});
},
- drag: function(event, ui) {
+ drag: function( event, ui, inst ) {
var ts, bs, ls, rs, l, r, t, b, i, first,
- inst = $(this).draggable( "instance" ),
o = inst.options,
d = o.snapTolerance,
x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
});
$.ui.plugin.add("draggable", "stack", {
- start: function() {
+ start: function( event, ui, instance ) {
var min,
- o = $(this).draggable( "instance" ).options,
+ o = instance.options,
group = $.makeArray($(o.stack)).sort(function(a,b) {
return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
});
});
$.ui.plugin.add("draggable", "zIndex", {
- start: function(event, ui) {
- var t = $(ui.helper), o = $(this).draggable( "instance" ).options;
+ start: function( event, ui, instance ) {
+ var t = $( ui.helper ),
+ o = instance.options;
+
if(t.css("zIndex")) {
o._zIndex = t.css("zIndex");
}
t.css("zIndex", o.zIndex);
},
- stop: function(event, ui) {
- var o = $(this).draggable( "instance" ).options;
+ stop: function( event, ui, instance ) {
+ var o = instance.options;
+
if(o._zIndex) {
$(ui.helper).css("zIndex", o._zIndex);
}