@@ -100,13 +100,13 @@ $.widget("ui.sortable", $.ui.mouse, {
100
100
this . _refreshItems ( event ) ;
101
101
102
102
//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 ) {
105
105
currentItem = $ ( this ) ;
106
106
return false ;
107
107
}
108
108
} ) ;
109
- if ( $ . data ( event . target , that . widgetName + '-item' ) == self ) currentItem = $ ( event . target ) ;
109
+ if ( $ . data ( event . target , that . widgetName + '-item' ) == that ) currentItem = $ ( event . target ) ;
110
110
111
111
if ( ! currentItem ) return false ;
112
112
if ( this . options . handle && ! overrideHandle ) {
@@ -124,7 +124,7 @@ $.widget("ui.sortable", $.ui.mouse, {
124
124
125
125
_mouseStart : function ( event , overrideHandle , noActivation ) {
126
126
127
- var o = this . options , self = this ;
127
+ var o = this . options ;
128
128
this . currentContainer = this ;
129
129
130
130
//We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
@@ -167,7 +167,7 @@ $.widget("ui.sortable", $.ui.mouse, {
167
167
// TODO: Still need to figure out a way to make relative sorting possible
168
168
this . helper . css ( "position" , "absolute" ) ;
169
169
this . cssPosition = this . helper . css ( "position" ) ;
170
-
170
+
171
171
//Generate the original position
172
172
this . originalPosition = this . _generatePosition ( event ) ;
173
173
this . originalPageX = event . pageX ;
@@ -220,7 +220,7 @@ $.widget("ui.sortable", $.ui.mouse, {
220
220
221
221
//Post 'activate' events to possible containers
222
222
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 ) ) ; }
224
224
}
225
225
226
226
//Prepare possible droppables
@@ -338,16 +338,16 @@ $.widget("ui.sortable", $.ui.mouse, {
338
338
$ . ui . ddmanager . drop ( this , event ) ;
339
339
340
340
if ( this . options . revert ) {
341
- var self = this ;
342
- var cur = self . placeholder . offset ( ) ;
341
+ var that = this ;
342
+ var cur = this . placeholder . offset ( ) ;
343
343
344
- self . reverting = true ;
344
+ this . reverting = true ;
345
345
346
346
$ ( 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 )
349
349
} , parseInt ( this . options . revert , 10 ) || 500 , function ( ) {
350
- self . _clear ( event ) ;
350
+ that . _clear ( event ) ;
351
351
} ) ;
352
352
} else {
353
353
this . _clear ( event , noPropagation ) ;
@@ -359,8 +359,6 @@ $.widget("ui.sortable", $.ui.mouse, {
359
359
360
360
cancel : function ( ) {
361
361
362
- var self = this ;
363
-
364
362
if ( this . dragging ) {
365
363
366
364
this . _mouseUp ( { target : null } ) ;
@@ -372,9 +370,9 @@ $.widget("ui.sortable", $.ui.mouse, {
372
370
373
371
//Post deactivating events to containers
374
372
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 ) ) ;
376
374
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 ) ) ;
378
376
this . containers [ i ] . containerCache . over = 0 ;
379
377
}
380
378
}
@@ -522,7 +520,6 @@ $.widget("ui.sortable", $.ui.mouse, {
522
520
523
521
_getItemsAsjQuery : function ( connected ) {
524
522
525
- var self = this ;
526
523
var items = [ ] ;
527
524
var queries = [ ] ;
528
525
var connectWith = this . _connectWith ( ) ;
@@ -571,7 +568,6 @@ $.widget("ui.sortable", $.ui.mouse, {
571
568
this . items = [ ] ;
572
569
this . containers = [ this ] ;
573
570
var items = this . items ;
574
- var self = this ;
575
571
var queries = [ [ $ . isFunction ( this . options . items ) ? this . options . items . call ( this . element [ 0 ] , event , { item : this . currentItem } ) : $ ( this . options . items , this . element ) , this ] ] ;
576
572
var connectWith = this . _connectWith ( ) ;
577
573
@@ -650,16 +646,16 @@ $.widget("ui.sortable", $.ui.mouse, {
650
646
} ,
651
647
652
648
_createPlaceholder : function ( that ) {
653
-
654
- var self = that || this , o = self . options ;
649
+ that = that || this ;
650
+ var o = that . options ;
655
651
656
652
if ( ! o . placeholder || o . placeholder . constructor == String ) {
657
653
var className = o . placeholder ;
658
654
o . placeholder = {
659
655
element : function ( ) {
660
656
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" )
663
659
. removeClass ( "ui-sortable-helper" ) [ 0 ] ;
664
660
665
661
if ( ! className )
@@ -674,20 +670,20 @@ $.widget("ui.sortable", $.ui.mouse, {
674
670
if ( className && ! o . forcePlaceholderSize ) return ;
675
671
676
672
//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 ) ) ; } ;
679
675
}
680
676
} ;
681
677
}
682
678
683
679
//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 ) ) ;
685
681
686
682
//Append it after the actual current item
687
- self . currentItem . after ( self . placeholder ) ;
683
+ that . currentItem . after ( that . placeholder ) ;
688
684
689
685
//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 ) ;
691
687
692
688
} ,
693
689
@@ -970,11 +966,11 @@ $.widget("ui.sortable", $.ui.mouse, {
970
966
// 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
971
967
// 4. this lets only the last addition to the timeout stack through
972
968
this . counter = this . counter ? ++ this . counter : 1 ;
973
- var self = this , counter = this . counter ;
969
+ var counter = this . counter ;
974
970
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
+ } ) ;
978
974
979
975
} ,
980
976
@@ -983,7 +979,7 @@ $.widget("ui.sortable", $.ui.mouse, {
983
979
this . reverting = false ;
984
980
// We delay all events that have to be triggered to after the point where the placeholder has been removed and
985
981
// everything else normalized again
986
- var delayedTriggers = [ ] , self = this ;
982
+ var delayedTriggers = [ ] ;
987
983
988
984
// We first have to update the dom position of the actual currentItem
989
985
// 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, {
1058
1054
}
1059
1055
} ,
1060
1056
1061
- _uiHash : function ( inst ) {
1062
- var self = inst || this ;
1057
+ _uiHash : function ( _inst ) {
1058
+ var inst = _inst || this ;
1063
1059
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
1071
1067
} ;
1072
1068
}
1073
1069
0 commit comments