Fixed #424 - missing onReorder

This commit is contained in:
Max Lynch
2014-01-16 11:19:11 -07:00
parent 3c2b1f8c68
commit c949532cfd
5 changed files with 35 additions and 4 deletions

View File

@@ -1495,7 +1495,12 @@ angular.module('ionic.ui.list', ['ngAnimate'])
link: function($scope, $element, $attr) {
$scope.listView = new ionic.views.ListView({
el: $element[0],
listEl: $element[0].children[0]
listEl: $element[0].children[0],
onReorder: function(el, oldIndex, newIndex) {
$scope.$apply(function() {
$scope.onReorder({el: el, start: oldIndex, end: newIndex});
});
}
});
if($attr.animation) {

View File

File diff suppressed because one or more lines are too long

View File

@@ -125,7 +125,12 @@ angular.module('ionic.ui.list', ['ngAnimate'])
link: function($scope, $element, $attr) {
$scope.listView = new ionic.views.ListView({
el: $element[0],
listEl: $element[0].children[0]
listEl: $element[0].children[0],
onReorder: function(el, oldIndex, newIndex) {
$scope.$apply(function() {
$scope.onReorder({el: el, start: oldIndex, end: newIndex});
});
}
});
if($attr.animation) {

View File

@@ -11,6 +11,7 @@ describe('Ionic List', function() {
}));
beforeEach(inject(function (_$compile_, _$rootScope_) {
compile = _$compile_;
scope.showDelete = false;
scope.showReorder = false;
@@ -56,6 +57,22 @@ describe('Ionic List', function() {
scope.$digest();
expect(listElement.hasClass('item-options-hide')).toBe(true);
});
it('Should reorder', function() {
scope.onReorder = function(el, start, end) {
};
listElement = angular.element('<list on-reorder="onReorder(el, start, end)"></list>');
listElement = compile(listElement)(scope);
var lv = listElement.isolateScope().listView;
spyOn(scope, 'onReorder');
lv.onReorder({}, 0, 1);
expect(scope.onReorder).toHaveBeenCalledWith({}, 0, 1);
});
});
describe('Ionic Item Directive', function () {

View File

@@ -104,6 +104,7 @@
on-refresh-holding="refreshHolding()"
on-refresh-opening="refreshOpening(ratio)"
on-refresh="refreshItems()"
on-reorder="onReorder(el, start, end)"
refresh-complete="refreshComplete"
on-delete="deleteListItem(item)"
delete-icon="ion-minus-circled"
@@ -223,6 +224,9 @@
alert('onDelete from the "list" on-delete attribute');
$scope.items.splice($scope.items.indexOf(item), 1);
};
$scope.onReorder = function(el, start, end) {
console.log('On reorder', el, start, end);
};
$scope.optionButtons1 = [
{