amend($ionicModal): if hardwareBackButtonClose false, back button is noop

Addresses #1397
This commit is contained in:
Andrew Joslin
2014-06-05 07:28:28 -06:00
parent 53af788da9
commit 9942045fb2
3 changed files with 10 additions and 8 deletions

View File

@@ -128,12 +128,10 @@ function($rootScope, $document, $compile, $timeout, $ionicPlatform, $ionicTempla
.removeClass('ng-leave ng-leave-active');
self._isShown = true;
self._deregisterBackButton = self.hardwareBackButtonClose ?
$ionicPlatform.registerBackButtonAction(
angular.bind(self, self.hide),
PLATFORM_BACK_BUTTON_PRIORITY_MODAL
) :
angular.noop;
self._deregisterBackButton = $ionicPlatform.registerBackButtonAction(
self.hardwareBackButtonClose ? angular.bind(self, self.hide) : angular.noop,
PLATFORM_BACK_BUTTON_PRIORITY_MODAL
);
self._isOpenPromise = $q.defer();

View File

View File

@@ -106,10 +106,14 @@ describe('Ionic Modal', function() {
var instance = modal.fromTemplate(template, {
hardwareBackButtonClose: false
});
spyOn($ionicPlatform, 'registerBackButtonAction');
spyOn($ionicPlatform, 'registerBackButtonAction').andCallThrough();
instance.show();
timeout.flush();
expect($ionicPlatform.registerBackButtonAction).not.toHaveBeenCalled();
expect($ionicPlatform.registerBackButtonAction).toHaveBeenCalledWith(jasmine.any(Function), PLATFORM_BACK_BUTTON_PRIORITY_MODAL);
ionicPlatform.hardwareBackButtonClick();
expect(instance.isShown()).toBe(true);
}));
it('should call _deregisterBackButton on hide', function() {