@@ -105,69 +105,6 @@ describe('uiSortable', function() {
105105 } ) ;
106106 } ) ;
107107
108- it ( 'should cancel sorting of nodes that contain "Two"' , function ( ) {
109- inject ( function ( $compile , $rootScope ) {
110- var elementTop , elementBottom ;
111- elementTop = $compile ( '<ul ui-sortable="opts" class="cross-sortable" ng-model="itemsTop"><li ng-repeat="item in itemsTop" id="s-top-{{$index}}">{{ item }}</li></ul>' ) ( $rootScope ) ;
112- elementBottom = $compile ( '<ul ui-sortable="opts" class="cross-sortable" ng-model="itemsBottom"><li ng-repeat="item in itemsBottom" id="s-bottom-{{$index}}">{{ item }}</li></ul>' ) ( $rootScope ) ;
113- $rootScope . $apply ( function ( ) {
114- $rootScope . itemsTop = [ 'Top One' , 'Top Two' , 'Top Three' ] ;
115- $rootScope . itemsBottom = [ 'Bottom One' , 'Bottom Two' , 'Bottom Three' ] ;
116- $rootScope . opts = {
117- connectWith : '.cross-sortable' ,
118- update : function ( e , ui ) {
119- if ( ui . item . scope ( ) &&
120- ( typeof ui . item . scope ( ) . item === 'string' ) &&
121- ui . item . scope ( ) . item . indexOf ( 'Two' ) >= 0 ) {
122- ui . item . sortable . cancel ( ) ;
123- }
124- }
125- } ;
126- } ) ;
127-
128- host . append ( elementTop ) . append ( elementBottom ) ;
129-
130- var li1 = elementTop . find ( ':eq(1)' ) ;
131- var li2 = elementBottom . find ( ':eq(0)' ) ;
132- var dy = EXTRA_DY_PERCENTAGE * li1 . outerHeight ( ) + ( li2 . position ( ) . top - li1 . position ( ) . top ) ;
133- li1 . simulate ( 'drag' , { dy : dy } ) ;
134- expect ( $rootScope . itemsTop ) . toEqual ( [ 'Top One' , 'Top Two' , 'Top Three' ] ) ;
135- expect ( $rootScope . itemsBottom ) . toEqual ( [ 'Bottom One' , 'Bottom Two' , 'Bottom Three' ] ) ;
136- expect ( $rootScope . itemsTop ) . toEqual ( listContent ( elementTop ) ) ;
137- expect ( $rootScope . itemsBottom ) . toEqual ( listContent ( elementBottom ) ) ;
138-
139- li1 = elementBottom . find ( ':eq(1)' ) ;
140- li2 = elementTop . find ( ':eq(1)' ) ;
141- dy = - EXTRA_DY_PERCENTAGE * li1 . outerHeight ( ) - ( li1 . position ( ) . top - li2 . position ( ) . top ) ;
142- li1 . simulate ( 'drag' , { dy : dy } ) ;
143- expect ( $rootScope . itemsTop ) . toEqual ( [ 'Top One' , 'Top Two' , 'Top Three' ] ) ;
144- expect ( $rootScope . itemsBottom ) . toEqual ( [ 'Bottom One' , 'Bottom Two' , 'Bottom Three' ] ) ;
145- expect ( $rootScope . itemsTop ) . toEqual ( listContent ( elementTop ) ) ;
146- expect ( $rootScope . itemsBottom ) . toEqual ( listContent ( elementBottom ) ) ;
147-
148- li1 = elementTop . find ( ':eq(0)' ) ;
149- li2 = elementBottom . find ( ':eq(0)' ) ;
150- dy = EXTRA_DY_PERCENTAGE * li1 . outerHeight ( ) + ( li2 . position ( ) . top - li1 . position ( ) . top ) ;
151- li1 . simulate ( 'drag' , { dy : dy } ) ;
152- expect ( $rootScope . itemsTop ) . toEqual ( [ 'Top Two' , 'Top Three' ] ) ;
153- expect ( $rootScope . itemsBottom ) . toEqual ( [ 'Bottom One' , 'Top One' , 'Bottom Two' , 'Bottom Three' ] ) ;
154- expect ( $rootScope . itemsTop ) . toEqual ( listContent ( elementTop ) ) ;
155- expect ( $rootScope . itemsBottom ) . toEqual ( listContent ( elementBottom ) ) ;
156-
157- li1 = elementBottom . find ( ':eq(1)' ) ;
158- li2 = elementTop . find ( ':eq(1)' ) ;
159- dy = - EXTRA_DY_PERCENTAGE * li1 . outerHeight ( ) - ( li1 . position ( ) . top - li2 . position ( ) . top ) ;
160- li1 . simulate ( 'drag' , { dy : dy } ) ;
161- expect ( $rootScope . itemsTop ) . toEqual ( [ 'Top Two' , 'Top One' , 'Top Three' ] ) ;
162- expect ( $rootScope . itemsBottom ) . toEqual ( [ 'Bottom One' , 'Bottom Two' , 'Bottom Three' ] ) ;
163- expect ( $rootScope . itemsTop ) . toEqual ( listContent ( elementTop ) ) ;
164- expect ( $rootScope . itemsBottom ) . toEqual ( listContent ( elementBottom ) ) ;
165-
166- $ ( elementTop ) . remove ( ) ;
167- $ ( elementBottom ) . remove ( ) ;
168- } ) ;
169- } ) ;
170-
171108 it ( 'should update model from update() callback' , function ( ) {
172109 inject ( function ( $compile , $rootScope ) {
173110 var element , logsElement ;
0 commit comments