mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Droppable: Added activate and deactivate events.
This commit is contained in:
parent
8ebdba7346
commit
74e2828ea0
19
ui/jquery.ui.droppable.js
vendored
19
ui/jquery.ui.droppable.js
vendored
@ -63,8 +63,12 @@ $.widget( "ui.droppable", {
|
|||||||
|
|
||||||
/** internal **/
|
/** internal **/
|
||||||
|
|
||||||
_accept: function( element ) {
|
_start: function( event, ui ) {
|
||||||
return this.options.accept ? element.is( this.options.accept ) : true;
|
if ( this.options.accept && !$( event.target ).is( this.options.accept ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._trigger( "activate", event, this._uiHash() );
|
||||||
},
|
},
|
||||||
|
|
||||||
_drag: function( event, ui ) {
|
_drag: function( event, ui ) {
|
||||||
@ -89,11 +93,13 @@ $.widget( "ui.droppable", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_dragStop: function( event, ui ) {
|
_stop: function( event, ui ) {
|
||||||
if ( this.over ) {
|
if ( this.over ) {
|
||||||
this._trigger( "drop", event, this._uiHash() );
|
this._trigger( "drop", event, this._uiHash() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._trigger( "deactivate", event, this._uiHash() );
|
||||||
|
|
||||||
this.over = false;
|
this.over = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -139,8 +145,7 @@ $.extend( $.ui.droppable, {
|
|||||||
|
|
||||||
_draggableStart: function( event, ui ) {
|
_draggableStart: function( event, ui ) {
|
||||||
var droppable,
|
var droppable,
|
||||||
target = $( event.target ),
|
element = ui.helper || $( event.target );
|
||||||
element = ui.helper || target;
|
|
||||||
|
|
||||||
this.draggableProportions = {
|
this.draggableProportions = {
|
||||||
width: element.outerWidth(),
|
width: element.outerWidth(),
|
||||||
@ -149,7 +154,7 @@ $.extend( $.ui.droppable, {
|
|||||||
|
|
||||||
this.active = [];
|
this.active = [];
|
||||||
for ( droppable in droppables ) {
|
for ( droppable in droppables ) {
|
||||||
if ( droppables[ droppable ]._accept( target ) ) {
|
if ( droppables[ droppable ]._start( event, ui ) !== false ) {
|
||||||
this.active.push( droppables[ droppable ] );
|
this.active.push( droppables[ droppable ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -163,7 +168,7 @@ $.extend( $.ui.droppable, {
|
|||||||
|
|
||||||
_draggableStop: function( event, ui ) {
|
_draggableStop: function( event, ui ) {
|
||||||
$.each( this.active, function() {
|
$.each( this.active, function() {
|
||||||
this._dragStop( event, ui );
|
this._stop( event, ui );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user