88( function ( $ ) {
99var dragging , placeholders = $ ( ) ;
1010$ . fn . sortable = function ( options ) {
11- options = options || { } ;
11+ var method = String ( options ) ;
12+ options = $ . extend ( {
13+ connectWith : false
14+ } , options ) ;
1215 return this . each ( function ( ) {
13- if ( / ^ e n a b l e | d i s a b l e | d e s t r o y $ / . test ( options ) ) {
14- var items = $ ( this ) . children ( $ ( this ) . data ( 'items' ) ) . attr ( 'draggable' , options == 'enable' ) ;
15- if ( options == 'destroy' ) {
16+ if ( / ^ e n a b l e | d i s a b l e | d e s t r o y $ / . test ( method ) ) {
17+ var items = $ ( this ) . children ( $ ( this ) . data ( 'items' ) ) . attr ( 'draggable' , method == 'enable' ) ;
18+ if ( method == 'destroy' ) {
1619 items . add ( this ) . removeData ( 'connectWith items' )
1720 . off ( 'dragstart.h5s dragend.h5s selectstart.h5s dragover.h5s dragenter.h5s drop.h5s' ) ;
1821 }
1922 return ;
2023 }
21- var index , items = $ ( this ) . children ( options . items ) , connectWith = options . connectWith || false ;
24+ var isHandle , index , items = $ ( this ) . children ( options . items ) ;
2225 var placeholder = $ ( '<' + items [ 0 ] . tagName + ' class="sortable-placeholder">' ) ;
23- var handle = options . handle , isHandle ;
24- items . find ( handle ) . mousedown ( function ( ) {
26+ items . find ( options . handle ) . mousedown ( function ( ) {
2527 isHandle = true ;
2628 } ) . mouseup ( function ( ) {
2729 isHandle = false ;
2830 } ) ;
2931 $ ( this ) . data ( 'items' , options . items )
3032 placeholders = placeholders . add ( placeholder ) ;
31- if ( connectWith ) {
32- $ ( connectWith ) . add ( this ) . data ( 'connectWith' , connectWith ) ;
33+ if ( options . connectWith ) {
34+ $ ( options . connectWith ) . add ( this ) . data ( 'connectWith' , options . connectWith ) ;
3335 }
3436 items . attr ( 'draggable' , 'true' ) . on ( 'dragstart.h5s' , function ( e ) {
35- if ( handle && ! isHandle ) {
37+ if ( options . handle && ! isHandle ) {
3638 return false ;
3739 }
3840 isHandle = false ;
@@ -52,7 +54,7 @@ $.fn.sortable = function(options) {
5254 this . dragDrop && this . dragDrop ( ) ;
5355 return false ;
5456 } ) . end ( ) . add ( [ this , placeholder ] ) . on ( 'dragover.h5s dragenter.h5s drop.h5s' , function ( e ) {
55- if ( ! items . is ( dragging ) && connectWith !== $ ( dragging ) . parent ( ) . data ( 'connectWith' ) ) {
57+ if ( ! items . is ( dragging ) && options . connectWith !== $ ( dragging ) . parent ( ) . data ( 'connectWith' ) ) {
5658 return true ;
5759 }
5860 if ( e . type == 'drop' ) {
0 commit comments