Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit 133297e

Browse files
committed
Merge pull request #95 from thgreasi/angular1.2
Cherry picking ui-project changes & tests from master
2 parents d9dd1b9 + 7e015b2 commit 133297e

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

demo/demo.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<section ng-app="sortableApp" ng-controller="sortableController">
22
<div class="row">
3-
<div class="span6">
3+
<div class="col-md-6">
44
<ul ui-sortable="sortableOptions" ng-model="list" class="list">
55
<li ng-repeat="item in list" class="item">{{item.text}}</li>
66
</ul>
77
</div>
8-
<div class="span6">
8+
<div class="col-md-6">
99
<ul class="list logList">
1010
<li ng-repeat="entry in sortingLog" class="logItem">{{entry.Text}}</li>
1111
</ul>

publish.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var path = require('path');
88
module.exports = function() {
99

1010
var js_dependencies =[
11+
'bower_components/jquery/jquery.js',
1112
'bower_components/jquery-ui/ui/jquery-ui.js'
1213
];
1314

@@ -25,7 +26,10 @@ module.exports = function() {
2526
inlineHTML : fs.readFileSync(__dirname + '/demo/demo.html'),
2627
inlineJS : fs.readFileSync(__dirname + '/demo/demo.js'),
2728
css: css_dependencies.map(putThemInVendorDir).concat(['demo/demo.css']),
28-
js : js_dependencies.map(putThemInVendorDir).concat(['dist/sortable.js']),
29+
js : function(defaultJsFiles){
30+
// HACK TO LOAD JQUERY BEFORE ANGULAR
31+
return ['vendor/jquery.js'].concat(defaultJsFiles, js_dependencies.slice(1).map(putThemInVendorDir).concat(['dist/sortable.js']));
32+
},
2933
tocopy : css_dependencies.concat(js_dependencies)
3034
};
3135
};

test/sortable.spec.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,42 @@ describe('uiSortable', function() {
400400
});
401401
});
402402

403+
it('should update model when sorting a "falsy" item between sortables', function() {
404+
inject(function($compile, $rootScope) {
405+
var elementTop, elementBottom;
406+
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);
407+
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);
408+
$rootScope.$apply(function() {
409+
$rootScope.itemsTop = [0, 'Top Two', 'Top Three'];
410+
$rootScope.itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
411+
$rootScope.opts = { connectWith: '.cross-sortable' };
412+
});
413+
414+
host.append(elementTop).append(elementBottom);
415+
416+
var li1 = elementTop.find(':eq(0)');
417+
var li2 = elementBottom.find(':eq(0)');
418+
var dy = EXTRA_DY_PERCENTAGE * li1.outerHeight() + (li2.position().top - li1.position().top);
419+
li1.simulate('drag', { dy: dy });
420+
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
421+
expect($rootScope.itemsBottom).toEqual(['Bottom One', 0, 'Bottom Two', 'Bottom Three']);
422+
expect($rootScope.itemsTop).toEqualListContent(elementTop);
423+
expect($rootScope.itemsBottom).toEqualListContent(elementBottom);
424+
425+
li1 = elementBottom.find(':eq(1)');
426+
li2 = elementTop.find(':eq(1)');
427+
dy = -EXTRA_DY_PERCENTAGE * li1.outerHeight() - (li1.position().top - li2.position().top);
428+
li1.simulate('drag', { dy: dy });
429+
expect($rootScope.itemsTop).toEqual(['Top Two', 0, 'Top Three']);
430+
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Bottom Two', 'Bottom Three']);
431+
expect($rootScope.itemsTop).toEqualListContent(elementTop);
432+
expect($rootScope.itemsBottom).toEqualListContent(elementBottom);
433+
434+
$(elementTop).remove();
435+
$(elementBottom).remove();
436+
});
437+
});
438+
403439
it('should work when "placeholder" option is used', function() {
404440
inject(function($compile, $rootScope) {
405441
var elementTop, elementBottom;

0 commit comments

Comments
 (0)