fix(ionList): disable swiping of items while option buttons are shown

Addresses #1202
This commit is contained in:
Andy Joslin
2014-04-25 06:49:17 -06:00
parent a845ff3489
commit 81676e6ef7
3 changed files with 29 additions and 8 deletions

View File

@@ -144,23 +144,27 @@ describe('ionList directive', function() {
});
it('should watch ctrl.showDelete when true', inject(function($animate) {
var el = setup('', '<div class="item-delete item-left-edit ng-hide"></div><div></div>');
var el = setup('', '<div class="item-delete item-left-edit ng-hide"></div><div></div><div class="item-content"></div></div>');
flush();
spyOn(el.controller('ionList'), 'closeOptionButtons');
el.controller('ionList').showDelete(true);
expect(el.controller('ionList').canSwipeItems()).toBe(true);
el.scope().$apply();
expect(el.controller('ionList').canSwipeItems()).toBe(false);
expect(el.controller('ionList').closeOptionButtons).toHaveBeenCalled();
var deleteButtons = angular.element(el[0].querySelectorAll('.item-delete.item-left-edit'));
expect(deleteButtons.length).not.toBe(0);
expect(deleteButtons.hasClass('ng-hide')).toBe(false);
expect(el.children().hasClass('list-left-editing')).toBe(true);
var content = angular.element(el[0].querySelectorAll('.item-content'));
expect(content.attr('data-tap-disabled')).toEqual('true');
}));
it('should watch ctrl.showDelete when false from true', inject(function($animate) {
var el = setup('', '<div class="item-delete item-left-edit"></div><div></div>');
var el = setup('', '<div class="item-delete item-left-edit"></div><div></div><div class="item-content">');
flush();
spyOn(el.controller('ionList'), 'closeOptionButtons');
@@ -170,27 +174,34 @@ describe('ionList directive', function() {
el.controller('ionList').showDelete(false);
el.scope().$apply();
expect(el.controller('ionList').canSwipeItems()).toBe(true);
expect(el.controller('ionList').closeOptionButtons.callCount).toBe(1);
var deleteButtons = angular.element(el[0].querySelectorAll('.item-delete.item-left-edit'));
expect(deleteButtons.hasClass('ng-hide')).toBe(true);
expect(deleteButtons.length).not.toBe(0);
expect(el.children().hasClass('list-left-editing')).toBe(false);
var content = angular.element(el[0].querySelectorAll('.item-content'));
expect(content.attr('data-tap-disabled')).toBeFalsy();
}));
it('should watch ctrl.showReorder when true', inject(function($animate) {
var el = setup('show-reorder="shouldReorder"', '<div class="item-reorder item-right-edit ng-hide"></div><div></div>');
var el = setup('show-reorder="shouldReorder"', '<div class="item-reorder item-right-edit ng-hide"></div><div class="item-content"></div><div></div>');
flush();
spyOn(el.controller('ionList'), 'closeOptionButtons');
el.controller('ionList').showReorder(true);
expect(el.controller('ionList').canSwipeItems()).toBe(true);
el.scope().$apply();
expect(el.controller('ionList').closeOptionButtons).toHaveBeenCalled();
expect(el.controller('ionList').canSwipeItems()).toBe(false);
var reorderButtons = angular.element(el[0].querySelectorAll('.item-reorder.item-right-edit'));
expect(reorderButtons.length).not.toBe(0);
expect(reorderButtons.hasClass('ng-hide')).toBe(false);
expect(el.children().hasClass('list-right-editing')).toBe(true);
var content = angular.element(el[0].querySelectorAll('.item-content'));
expect(content.attr('data-tap-disabled')).toEqual('true');
}));
it('should watch ctrl.showReorder when false from true', inject(function($animate) {
@@ -204,11 +215,14 @@ describe('ionList directive', function() {
el.controller('ionList').showReorder(false);
el.scope().$apply();
expect(el.controller('ionList').canSwipeItems()).toBe(true);
expect(el.controller('ionList').closeOptionButtons.callCount).toBe(1);
var reorderButtons = angular.element(el[0].querySelectorAll('.item-reorder.item-right-edit'));
expect(reorderButtons.length).not.toBe(0);
expect(reorderButtons.hasClass('ng-hide')).toBe(true);
expect(el.children().hasClass('list-right-editing')).toBe(false);
var content = angular.element(el[0].querySelectorAll('.item-content'));
expect(content.attr('data-tap-disabled')).toBeFalsy();
}));
});