From 74e2828ea09e36744b3992bca29ffc0b4a493b33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Sun, 29 Jan 2012 13:04:40 -0500 Subject: [PATCH] Droppable: Added activate and deactivate events. --- ui/jquery.ui.droppable.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ui/jquery.ui.droppable.js b/ui/jquery.ui.droppable.js index 69fc0d2e2..46cae9455 100644 --- a/ui/jquery.ui.droppable.js +++ b/ui/jquery.ui.droppable.js @@ -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 ); }); } });