Skip to content

Commit

Permalink
fix(ionNavBar): adjust has-header if ionNavBar is hidden
Browse files Browse the repository at this point in the history
Fixes #927.
  • Loading branch information
ajoslin committed Mar 27, 2014
1 parent 75290a3 commit 41b73ab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion js/ext/angular/src/directive/ionicNavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ function($scope, $element, $attrs, $ionicViewService, $animate, $compile, $ionic

this.showBar = function(show) {
$scope.isInvisible = !show;
$scope.$parent.$hasHeader = !!show;
};

this.setTitle = function(title) {
Expand Down Expand Up @@ -290,7 +291,6 @@ function($ionicViewService, $rootScope, $animate, $compile) {
$scope.shouldAnimate = true;
$scope.isReverse = false;
$scope.isInvisible = true;
$scope.$parent.$hasHeader = true;

$scope.$on('$destroy', function() {
$scope.$parent.$hasHeader = false;
Expand Down
16 changes: 13 additions & 3 deletions js/ext/angular/test/directive/ionicNavBar.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('ionNavBar', function() {
expect($scope.backButtonShown).toBe(false);
});

it('should showBar', function() {
it('showBar should set isInvisible', function() {
var ctrl = setup();
expect($scope.isInvisible).toBeUndefined();
ctrl.showBar(true);
Expand All @@ -83,6 +83,15 @@ describe('ionNavBar', function() {
expect($scope.isInvisible).toBe(true);
});

it('showBar should set $parent.$hasHeader', function() {
var ctrl = setup();
expect($scope.$parent.$hasHeader).toBeUndefined();
ctrl.showBar(true);
expect($scope.$parent.$hasHeader).toBe(true);
ctrl.showBar(false);
expect($scope.$parent.$hasHeader).toBe(false);
});

it('should setTitle', function() {
var ctrl = setup();
expect($scope.title).toBeFalsy();
Expand Down Expand Up @@ -230,10 +239,10 @@ describe('ionNavBar', function() {
expect(el.children().eq(0).html()).toBe('<b>super</b> content 4');
});

it('should $parent.$hasHeader and unset on $destroy', function() {
it('should set $parent.$hasHeader to false on $scope.$destroy', function() {
var el = setup();
var parentScope = el.scope().$parent;
expect(parentScope.$hasHeader).toBe(true);
parentScope.$hasHeader = true;
el.scope().$destroy();
expect(parentScope.$hasHeader).toBe(false);
});
Expand All @@ -255,6 +264,7 @@ describe('ionNavBar', function() {

it('should have invisible class (default true)', function() {
var el = setup();
el.scope().$apply();
expect(el.hasClass('invisible')).toBe(true);
el.scope().$apply('isInvisible = false');
expect(el.hasClass('invisible')).toBe(false);
Expand Down

0 comments on commit 41b73ab

Please sign in to comment.