From 74a05a03388f1a9a77141f078623b018bf2829eb Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Mon, 10 Feb 2014 15:07:20 -0600 Subject: [PATCH] fix(backButton): able to hide back button if any back button attr set in navBar, closes #564 --- .../angular/src/directive/ionicViewState.js | 2 +- .../angular/test/directive/ionicView.unit.js | 32 +++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/js/ext/angular/src/directive/ionicViewState.js b/js/ext/angular/src/directive/ionicViewState.js index 45c5690d69..f358599015 100644 --- a/js/ext/angular/src/directive/ionicViewState.js +++ b/js/ext/angular/src/directive/ionicViewState.js @@ -95,7 +95,7 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu if(tAttrs.type) tElement.addClass(tAttrs.type); return function link($scope, $element, $attr) { - var canHaveBackButton = !(!tAttrs.backButtonType && !tAttrs.backButtonLabel); + var canHaveBackButton = !(!tAttrs.backButtonType && !tAttrs.backButtonLabel && !tAttrs.backButtonIcon); $scope.enableBackButton = canHaveBackButton; $rootScope.$on('viewState.showNavBar', function(e, showNavBar) { diff --git a/js/ext/angular/test/directive/ionicView.unit.js b/js/ext/angular/test/directive/ionicView.unit.js index 089ddde7bc..62a09d6bfb 100644 --- a/js/ext/angular/test/directive/ionicView.unit.js +++ b/js/ext/angular/test/directive/ionicView.unit.js @@ -83,13 +83,41 @@ describe('Ionic View', function() { expect(element.hasClass('bar-positive')).toEqual(true); }); - it('should not show the back button if no back button attributes set', function() { + it('should not have the back button if no back button attributes set', function() { var element = compile('')(scope); scope.$digest(); var backButton = element.find('div').find('button'); expect(backButton.length).toEqual(0); }); + it('should have the back button if back-button-type attributes set', function() { + var element = compile('')(scope); + scope.$digest(); + var backButton = element.find('div').find('button'); + expect(backButton.length).toEqual(1); + }); + + it('should have the back button if back-button-icon attributes set', function() { + var element = compile('')(scope); + scope.$digest(); + var backButton = element.find('div').find('button'); + expect(backButton.length).toEqual(1); + }); + + it('should have the back button if back-button-label attributes set', function() { + var element = compile('')(scope); + scope.$digest(); + var backButton = element.find('div').find('button'); + expect(backButton.length).toEqual(1); + }); + + it('should have the back button if all back button attributes set', function() { + var element = compile('')(scope); + scope.$digest(); + var backButton = element.find('div').find('button'); + expect(backButton.length).toEqual(1); + }); + it('should set just a back button icon, no text', function() { var element = compile('')(scope); scope.$digest(); @@ -111,7 +139,7 @@ describe('Ionic View', function() { expect(backButton.html()).toEqual('Back'); }); - it('should set a back button with an icon and text, button-clear', function() { + it('should set a back button with an icon and text, button-icon', function() { var element = compile('')(scope); scope.$digest(); var backButton = element.find('div').find('button');