@@ -148,7 +148,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
148148 this . _setContainment ( ) ;
149149
150150 //Call plugins and callbacks
151- this . _propagate ( "start" , event ) ;
151+ this . _trigger ( "start" , event ) ;
152152
153153 //Recache the helper size
154154 if ( ! this . _preserveHelperProportions )
@@ -157,7 +157,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
157157
158158 //Post 'activate' events to possible containers
159159 if ( ! noActivation ) {
160- for ( var i = this . containers . length - 1 ; i >= 0 ; i -- ) { this . containers [ i ] . _propagate ( "activate" , event , this ) ; }
160+ for ( var i = this . containers . length - 1 ; i >= 0 ; i -- ) { this . containers [ i ] . _trigger ( "activate" , event , this ) ; }
161161 }
162162
163163 //Prepare possible droppables
@@ -216,7 +216,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
216216 break ;
217217 }
218218
219- this . _propagate ( "change" , event ) ; //Call plugins and callbacks
219+ this . _trigger ( "change" , event ) ; //Call plugins and callbacks
220220 break ;
221221 }
222222 }
@@ -276,9 +276,9 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
276276
277277 //Post deactivating events to containers
278278 for ( var i = this . containers . length - 1 ; i >= 0 ; i -- ) {
279- this . containers [ i ] . _propagate ( "deactivate" , null , this ) ;
279+ this . containers [ i ] . _trigger ( "deactivate" , null , this ) ;
280280 if ( this . containers [ i ] . containerCache . over ) {
281- this . containers [ i ] . _propagate ( "out" , null , this ) ;
281+ this . containers [ i ] . _trigger ( "out" , null , this ) ;
282282 this . containers [ i ] . containerCache . over = 0 ;
283283 }
284284 }
@@ -608,20 +608,20 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
608608
609609 this . currentContainer = this . containers [ i ] ;
610610 itemWithLeastDistance ? this . options . sortIndicator . call ( this , event , itemWithLeastDistance , null , true ) : this . options .sortIndicator . call ( this , event , null , this . containers [ i ] . element , true ) ;
611- this . _propagate ( "change" , event ) ; //Call plugins and callbacks
612- this . containers [ i ] . _propagate ( "change" , event , this ) ; //Call plugins and callbacks
611+ this . _trigger ( "change" , event ) ; //Call plugins and callbacks
612+ this . containers [ i ] . _trigger ( "change" , event , this ) ; //Call plugins and callbacks
613613
614614 //Update the placeholder
615615 this . options . placeholder . update ( this . currentContainer , this . placeholder ) ;
616616
617617 }
618618
619- this . containers [ i ] . _propagate ( "over" , event , this ) ;
619+ this . containers [ i ] . _trigger ( "over" , event , this ) ;
620620 this . containers [ i ] . containerCache . over = 1 ;
621621 }
622622 } else {
623623 if ( this . containers [ i ] . containerCache . over ) {
624- this . containers [ i ] . _propagate ( "out" , event , this ) ;
624+ this . containers [ i ] . _trigger ( "out" , event , this ) ;
625625 this . containers [ i ] . containerCache . over = 0 ;
626626 }
627627 }
@@ -828,49 +828,51 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
828828 this . currentItem . show ( ) ;
829829 }
830830
831- if ( this . domPosition . prev != this . currentItem . prev ( ) . not ( "." + this . options . cssNamespace + "-sortable-helper" ) [ 0 ] || this . domPosition . parent != this . currentItem . parent ( ) [ 0 ] ) this . _propagate ( "update" , event , null , noPropagation ) ; //Trigger update callback if the DOM position has changed
831+ if ( this . fromOutside ) this . _trigger ( "receive" , event , this , noPropagation ) ;
832+ if ( this . fromOutside || this . domPosition . prev != this . currentItem . prev ( ) . not ( "." + this . options . cssNamespace + "-sortable-helper" ) [ 0 ] || this . domPosition . parent != this . currentItem . parent ( ) [ 0 ] ) this . _trigger ( "update" , event , null , noPropagation ) ; //Trigger update callback if the DOM position has changed
832833 if ( ! $ . ui . contains ( this . element [ 0 ] , this . currentItem [ 0 ] ) ) { //Node was moved out of the current element
833- this . _propagate ( "remove" , event , null , noPropagation ) ;
834+ this . _trigger ( "remove" , event , null , noPropagation ) ;
834835 for ( var i = this . containers . length - 1 ; i >= 0 ; i -- ) {
835836 if ( $ . ui . contains ( this . containers [ i ] . element [ 0 ] , this . currentItem [ 0 ] ) ) {
836- this . containers [ i ] . _propagate ( "update ", event , this , noPropagation ) ;
837- this . containers [ i ] . _propagate ( "receive ", event , this , noPropagation ) ;
837+ this . containers [ i ] . _trigger ( "receive ", event , this , noPropagation ) ;
838+ this . containers [ i ] . _trigger ( "update ", event , this , noPropagation ) ;
838839 }
839840 } ;
840841 } ;
841842
842843 //Post events to containers
843844 for ( var i = this . containers . length - 1 ; i >= 0 ; i -- ) {
844- this . containers [ i ] . _propagate ( "deactivate" , event , this , noPropagation ) ;
845+ this . containers [ i ] . _trigger ( "deactivate" , event , this , noPropagation ) ;
845846 if ( this . containers [ i ] . containerCache . over ) {
846- this . containers [ i ] . _propagate ( "out" , event , this ) ;
847+ this . containers [ i ] . _trigger ( "out" , event , this ) ;
847848 this . containers [ i ] . containerCache . over = 0 ;
848849 }
849850 }
850851
851852 this . dragging = false ;
852853 if ( this . cancelHelperRemoval ) {
853- this . _propagate ( "beforeStop" , event , null , noPropagation ) ;
854- this . _propagate ( "stop" , event , null , noPropagation ) ;
854+ this . _trigger ( "beforeStop" , event , null , noPropagation ) ;
855+ this . _trigger ( "stop" , event , null , noPropagation ) ;
855856 return false ;
856857 }
857858
858- this . _propagate ( "beforeStop" , event , null , noPropagation ) ;
859+ this . _trigger ( "beforeStop" , event , null , noPropagation ) ;
859860
860861 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
861862 this . placeholder [ 0 ] . parentNode . removeChild ( this . placeholder [ 0 ] ) ;
862863
863- if ( this . options . helper != "original" ) this . helper . remove ( ) ; this . helper = null ;
864- this . _propagate ( "stop" , event , null , noPropagation ) ;
864+ if ( this . helper [ 0 ] != this . currentItem [ 0 ] ) this . helper . remove ( ) ; this . helper = null ;
865+ this . _trigger ( "stop" , event , null , noPropagation ) ;
865866
867+ this . fromOutside = false ;
866868 return true ;
867869
868870 } ,
869871
870- _propagate : function ( n , event , inst , noPropagation ) {
871- $ . ui . plugin . call ( this , n , [ event , this . _ui( inst ) ] ) ;
872- var dontCancel = ! noPropagation ? this . element . triggerHandler ( n == "sort" ? n : "sort" + n , [ event , this . _ui ( inst ) ] , this . options [ n ] ) : true ;
873- if ( dontCancel === false ) this . cancel ( ) ;
872+ _trigger : function ( type , event , inst , noPropagation ) {
873+ $ . ui . plugin . call ( this , type , [ event , this . _ui ( inst ) ] ) ;
874+ if ( ! noPropagation ) $ . widget . prototype . _trigger . call ( this , type , event , this . _ui ( inst ) ) ;
875+ if ( event . returnValue === false ) this . cancel ( ) ;
874876 } ,
875877
876878 plugins : { } ,
0 commit comments