Droppable: Added activate and deactivate events.

This commit is contained in:
Scott González 2012-01-29 13:04:40 -05:00
parent 8ebdba7346
commit 74e2828ea0

View File

@ -63,8 +63,12 @@ $.widget( "ui.droppable", {
/** internal **/
_accept: function( element ) {
return this.options.accept ? element.is( this.options.accept ) : true;
_start: function( event, ui ) {
if ( this.options.accept && !$( event.target ).is( this.options.accept ) ) {
return false;
}
this._trigger( "activate", event, this._uiHash() );
},
_drag: function( event, ui ) {
@ -89,11 +93,13 @@ $.widget( "ui.droppable", {
}
},
_dragStop: function( event, ui ) {
_stop: function( event, ui ) {
if ( this.over ) {
this._trigger( "drop", event, this._uiHash() );
}
this._trigger( "deactivate", event, this._uiHash() );
this.over = false;
},
@ -139,8 +145,7 @@ $.extend( $.ui.droppable, {
_draggableStart: function( event, ui ) {
var droppable,
target = $( event.target ),
element = ui.helper || target;
element = ui.helper || $( event.target );
this.draggableProportions = {
width: element.outerWidth(),
@ -149,7 +154,7 @@ $.extend( $.ui.droppable, {
this.active = [];
for ( droppable in droppables ) {
if ( droppables[ droppable ]._accept( target ) ) {
if ( droppables[ droppable ]._start( event, ui ) !== false ) {
this.active.push( droppables[ droppable ] );
}
}
@ -163,7 +168,7 @@ $.extend( $.ui.droppable, {
_draggableStop: function( event, ui ) {
$.each( this.active, function() {
this._dragStop( event, ui );
this._stop( event, ui );
});
}
});