mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Draggable: Got the easier failing unit tests corrected
This commit is contained in:
parent
15e3f28c4f
commit
86dcc5ea8f
@ -106,13 +106,10 @@ test("{ cancel: ? }, unexpected", function() {
|
|||||||
"{}": {},
|
"{}": {},
|
||||||
"[]": [],
|
"[]": [],
|
||||||
"null": null,
|
"null": null,
|
||||||
"undefined": undefined,
|
"undefined": undefined
|
||||||
"function() {return '';}": function() {return '';},
|
|
||||||
"function() {return true;}": function() {return true;},
|
|
||||||
"function() {return false;}": function() {return false;}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
expect( 9 );
|
expect( 6 );
|
||||||
|
|
||||||
$.each(unexpected, function(key, val) {
|
$.each(unexpected, function(key, val) {
|
||||||
el = $("#draggable2").draggable({ cancel: val });
|
el = $("#draggable2").draggable({ cancel: val });
|
||||||
|
65
ui/jquery.ui.draggable.js
vendored
65
ui/jquery.ui.draggable.js
vendored
@ -77,7 +77,7 @@ $.widget( "ui.draggable", $.ui.interaction, {
|
|||||||
var offset;
|
var offset;
|
||||||
|
|
||||||
// The actual dragging element, should always be a jQuery object
|
// The actual dragging element, should always be a jQuery object
|
||||||
this.dragEl = this.options.helper ?
|
this.dragEl = ( this.options.helper === true || typeof this.options.helper === 'function' ) ?
|
||||||
this._createHelper( pointerPosition ) :
|
this._createHelper( pointerPosition ) :
|
||||||
this.element;
|
this.element;
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ $.widget( "ui.draggable", $.ui.interaction, {
|
|||||||
};
|
};
|
||||||
offset = this.dragEl.offset();
|
offset = this.dragEl.offset();
|
||||||
this.dragEl
|
this.dragEl
|
||||||
.appendTo( this.options.appendTo )
|
.appendTo( this._appendToEl() )
|
||||||
.offset( offset );
|
.offset( offset );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ $.widget( "ui.draggable", $.ui.interaction, {
|
|||||||
|
|
||||||
// Ensure the helper is in the DOM; obey the appendTo option if it exists
|
// Ensure the helper is in the DOM; obey the appendTo option if it exists
|
||||||
if ( this.options.appendTo || !helper.closest( "body" ).length ) {
|
if ( this.options.appendTo || !helper.closest( "body" ).length ) {
|
||||||
helper.appendTo( this.options.appendTo || this.document[0].body );
|
helper.appendTo( this._appendToEl() || this.document[0].body );
|
||||||
}
|
}
|
||||||
|
|
||||||
return helper
|
return helper
|
||||||
@ -220,6 +220,11 @@ $.widget( "ui.draggable", $.ui.interaction, {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// TODO: Remove after 2.0, only used for backCompat
|
||||||
|
_appendToEl: function() {
|
||||||
|
return this.options.appendTo;
|
||||||
|
},
|
||||||
|
|
||||||
_getPosition: function() {
|
_getPosition: function() {
|
||||||
var left, top, position,
|
var left, top, position,
|
||||||
scrollTop = this.scrollParent.scrollTop(),
|
scrollTop = this.scrollParent.scrollTop(),
|
||||||
@ -481,6 +486,60 @@ $.widget( "ui.draggable", $.ui.draggable, {
|
|||||||
// DEPRECATED
|
// DEPRECATED
|
||||||
if ( $.uiBackCompat !== false ) {
|
if ( $.uiBackCompat !== false ) {
|
||||||
|
|
||||||
|
// appendTo 'parent' value
|
||||||
|
$.widget( "ui.draggable", $.ui.draggable, {
|
||||||
|
|
||||||
|
_appendToEl: function() {
|
||||||
|
|
||||||
|
var el = this.options.appendTo;
|
||||||
|
|
||||||
|
if ( el === 'parent' ) {
|
||||||
|
el = this.dragEl.parent();
|
||||||
|
}
|
||||||
|
|
||||||
|
return el;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// helper 'original' or 'clone' value
|
||||||
|
$.widget( "ui.draggable", $.ui.draggable, {
|
||||||
|
|
||||||
|
_create: function() {
|
||||||
|
|
||||||
|
this._super();
|
||||||
|
|
||||||
|
if ( this.options.helper === 'original' ) {
|
||||||
|
this.options.helper = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( this.options.helper === 'clone' ) {
|
||||||
|
this.options.helper = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
_setOption: function( key, value ) {
|
||||||
|
|
||||||
|
if ( key !== 'helper' ) {
|
||||||
|
return this._super( key, value );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( value === 'clone' ) {
|
||||||
|
value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( value === 'original' ) {
|
||||||
|
value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._super( key, value );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
// axis option
|
// axis option
|
||||||
$.widget( "ui.draggable", $.ui.draggable, {
|
$.widget( "ui.draggable", $.ui.draggable, {
|
||||||
options: {
|
options: {
|
||||||
|
Loading…
Reference in New Issue
Block a user