@@ -100,13 +100,13 @@ $.widget("ui.sortable", $.ui.mouse, {
100100 this . _refreshItems ( event ) ;
101101
102102 //Find out if the clicked node (or one of its parents) is a actual item in this.items
103- var currentItem = null , self = this , nodes = $ ( event . target ) . parents ( ) . each ( function ( ) {
104- if ( $ . data ( this , that . widgetName + '-item' ) == self ) {
103+ var currentItem = null , nodes = $ ( event . target ) . parents ( ) . each ( function ( ) {
104+ if ( $ . data ( this , that . widgetName + '-item' ) == that ) {
105105 currentItem = $ ( this ) ;
106106 return false ;
107107 }
108108 } ) ;
109- if ( $ . data ( event . target , that . widgetName + '-item' ) == self ) currentItem = $ ( event . target ) ;
109+ if ( $ . data ( event . target , that . widgetName + '-item' ) == that ) currentItem = $ ( event . target ) ;
110110
111111 if ( ! currentItem ) return false ;
112112 if ( this . options . handle && ! overrideHandle ) {
@@ -124,7 +124,7 @@ $.widget("ui.sortable", $.ui.mouse, {
124124
125125 _mouseStart : function ( event , overrideHandle , noActivation ) {
126126
127- var o = this . options , self = this ;
127+ var o = this . options ;
128128 this . currentContainer = this ;
129129
130130 //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
@@ -167,7 +167,7 @@ $.widget("ui.sortable", $.ui.mouse, {
167167 // TODO: Still need to figure out a way to make relative sorting possible
168168 this . helper . css ( "position" , "absolute" ) ;
169169 this . cssPosition = this . helper . css ( "position" ) ;
170-
170+
171171 //Generate the original position
172172 this . originalPosition = this . _generatePosition ( event ) ;
173173 this . originalPageX = event . pageX ;
@@ -220,7 +220,7 @@ $.widget("ui.sortable", $.ui.mouse, {
220220
221221 //Post 'activate' events to possible containers
222222 if ( ! noActivation ) {
223- for ( var i = this . containers . length - 1 ; i >= 0 ; i -- ) { this . containers [ i ] . _trigger ( "activate" , event , self . _uiHash ( this ) ) ; }
223+ for ( var i = this . containers . length - 1 ; i >= 0 ; i -- ) { this . containers [ i ] . _trigger ( "activate" , event , this . _uiHash ( this ) ) ; }
224224 }
225225
226226 //Prepare possible droppables
@@ -338,16 +338,16 @@ $.widget("ui.sortable", $.ui.mouse, {
338338 $ . ui . ddmanager . drop ( this , event ) ;
339339
340340 if ( this . options . revert ) {
341- var self = this ;
342- var cur = self . placeholder . offset ( ) ;
341+ var that = this ;
342+ var cur = this . placeholder . offset ( ) ;
343343
344- self . reverting = true ;
344+ this . reverting = true ;
345345
346346 $ ( this . helper ) . animate ( {
347- left : cur . left - this . offset . parent . left - self . margins . left + ( this . offsetParent [ 0 ] == document . body ? 0 : this . offsetParent [ 0 ] . scrollLeft ) ,
348- top : cur . top - this . offset . parent . top - self . margins . top + ( this . offsetParent [ 0 ] == document . body ? 0 : this . offsetParent [ 0 ] . scrollTop )
347+ left : cur . left - this . offset . parent . left - this . margins . left + ( this . offsetParent [ 0 ] == document . body ? 0 : this . offsetParent [ 0 ] . scrollLeft ) ,
348+ top : cur . top - this . offset . parent . top - this . margins . top + ( this . offsetParent [ 0 ] == document . body ? 0 : this . offsetParent [ 0 ] . scrollTop )
349349 } , parseInt ( this . options . revert , 10 ) || 500 , function ( ) {
350- self . _clear ( event ) ;
350+ that . _clear ( event ) ;
351351 } ) ;
352352 } else {
353353 this . _clear ( event , noPropagation ) ;
@@ -359,8 +359,6 @@ $.widget("ui.sortable", $.ui.mouse, {
359359
360360 cancel : function ( ) {
361361
362- var self = this ;
363-
364362 if ( this . dragging ) {
365363
366364 this . _mouseUp ( { target : null } ) ;
@@ -372,9 +370,9 @@ $.widget("ui.sortable", $.ui.mouse, {
372370
373371 //Post deactivating events to containers
374372 for ( var i = this . containers . length - 1 ; i >= 0 ; i -- ) {
375- this . containers [ i ] . _trigger ( "deactivate" , null , self . _uiHash ( this ) ) ;
373+ this . containers [ i ] . _trigger ( "deactivate" , null , this . _uiHash ( this ) ) ;
376374 if ( this . containers [ i ] . containerCache . over ) {
377- this . containers [ i ] . _trigger ( "out" , null , self . _uiHash ( this ) ) ;
375+ this . containers [ i ] . _trigger ( "out" , null , this . _uiHash ( this ) ) ;
378376 this . containers [ i ] . containerCache . over = 0 ;
379377 }
380378 }
@@ -522,7 +520,6 @@ $.widget("ui.sortable", $.ui.mouse, {
522520
523521 _getItemsAsjQuery : function ( connected ) {
524522
525- var self = this ;
526523 var items = [ ] ;
527524 var queries = [ ] ;
528525 var connectWith = this . _connectWith ( ) ;
@@ -571,7 +568,6 @@ $.widget("ui.sortable", $.ui.mouse, {
571568 this . items = [ ] ;
572569 this . containers = [ this ] ;
573570 var items = this . items ;
574- var self = this ;
575571 var queries = [ [ $ . isFunction ( this . options . items ) ? this . options . items . call ( this . element [ 0 ] , event , { item : this . currentItem } ) : $ ( this . options . items , this . element ) , this ] ] ;
576572 var connectWith = this . _connectWith ( ) ;
577573
@@ -650,16 +646,16 @@ $.widget("ui.sortable", $.ui.mouse, {
650646 } ,
651647
652648 _createPlaceholder : function ( that ) {
653-
654- var self = that || this , o = self . options ;
649+ that = that || this ;
650+ var o = that . options ;
655651
656652 if ( ! o . placeholder || o . placeholder . constructor == String ) {
657653 var className = o . placeholder ;
658654 o . placeholder = {
659655 element : function ( ) {
660656
661- var el = $ ( document . createElement ( self . currentItem [ 0 ] . nodeName ) )
662- . addClass ( className || self . currentItem [ 0 ] . className + " ui-sortable-placeholder" )
657+ var el = $ ( document . createElement ( that . currentItem [ 0 ] . nodeName ) )
658+ . addClass ( className || that . currentItem [ 0 ] . className + " ui-sortable-placeholder" )
663659 . removeClass ( "ui-sortable-helper" ) [ 0 ] ;
664660
665661 if ( ! className )
@@ -674,20 +670,20 @@ $.widget("ui.sortable", $.ui.mouse, {
674670 if ( className && ! o . forcePlaceholderSize ) return ;
675671
676672 //If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
677- if ( ! p . height ( ) ) { p . height ( self . currentItem . innerHeight ( ) - parseInt ( self . currentItem . css ( 'paddingTop' ) || 0 , 10 ) - parseInt ( self . currentItem . css ( 'paddingBottom' ) || 0 , 10 ) ) ; } ;
678- if ( ! p . width ( ) ) { p . width ( self . currentItem . innerWidth ( ) - parseInt ( self . currentItem . css ( 'paddingLeft' ) || 0 , 10 ) - parseInt ( self . currentItem . css ( 'paddingRight' ) || 0 , 10 ) ) ; } ;
673+ if ( ! p . height ( ) ) { p . height ( that . currentItem . innerHeight ( ) - parseInt ( that . currentItem . css ( 'paddingTop' ) || 0 , 10 ) - parseInt ( that . currentItem . css ( 'paddingBottom' ) || 0 , 10 ) ) ; } ;
674+ if ( ! p . width ( ) ) { p . width ( that . currentItem . innerWidth ( ) - parseInt ( that . currentItem . css ( 'paddingLeft' ) || 0 , 10 ) - parseInt ( that . currentItem . css ( 'paddingRight' ) || 0 , 10 ) ) ; } ;
679675 }
680676 } ;
681677 }
682678
683679 //Create the placeholder
684- self . placeholder = $ ( o . placeholder . element . call ( self . element , self . currentItem ) ) ;
680+ that . placeholder = $ ( o . placeholder . element . call ( that . element , that . currentItem ) ) ;
685681
686682 //Append it after the actual current item
687- self . currentItem . after ( self . placeholder ) ;
683+ that . currentItem . after ( that . placeholder ) ;
688684
689685 //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
690- o . placeholder . update ( self , self . placeholder ) ;
686+ o . placeholder . update ( that , that . placeholder ) ;
691687
692688 } ,
693689
@@ -970,11 +966,11 @@ $.widget("ui.sortable", $.ui.mouse, {
970966 // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
971967 // 4. this lets only the last addition to the timeout stack through
972968 this . counter = this . counter ? ++ this . counter : 1 ;
973- var self = this , counter = this . counter ;
969+ var counter = this . counter ;
974970
975- window . setTimeout ( function ( ) {
976- if ( counter == self . counter ) self . refreshPositions ( ! hardRefresh ) ; //Precompute after each DOM insertion, NOT on mousemove
977- } , 0 ) ;
971+ this . _delay ( function ( ) {
972+ if ( counter == this . counter ) this . refreshPositions ( ! hardRefresh ) ; //Precompute after each DOM insertion, NOT on mousemove
973+ } ) ;
978974
979975 } ,
980976
@@ -983,7 +979,7 @@ $.widget("ui.sortable", $.ui.mouse, {
983979 this . reverting = false ;
984980 // We delay all events that have to be triggered to after the point where the placeholder has been removed and
985981 // everything else normalized again
986- var delayedTriggers = [ ] , self = this ;
982+ var delayedTriggers = [ ] ;
987983
988984 // We first have to update the dom position of the actual currentItem
989985 // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
@@ -1058,16 +1054,16 @@ $.widget("ui.sortable", $.ui.mouse, {
10581054 }
10591055 } ,
10601056
1061- _uiHash : function ( inst ) {
1062- var self = inst || this ;
1057+ _uiHash : function ( _inst ) {
1058+ var inst = _inst || this ;
10631059 return {
1064- helper : self . helper ,
1065- placeholder : self . placeholder || $ ( [ ] ) ,
1066- position : self . position ,
1067- originalPosition : self . originalPosition ,
1068- offset : self . positionAbs ,
1069- item : self . currentItem ,
1070- sender : inst ? inst . element : null
1060+ helper : inst . helper ,
1061+ placeholder : inst . placeholder || $ ( [ ] ) ,
1062+ position : inst . position ,
1063+ originalPosition : inst . originalPosition ,
1064+ offset : inst . positionAbs ,
1065+ item : inst . currentItem ,
1066+ sender : _inst ? _inst . element : null
10711067 } ;
10721068 }
10731069
0 commit comments