fix(ionNavBar): adjust has-header if ionNavBar is hidden

Fixes #927.
This commit is contained in:
Andy Joslin
2014-03-27 06:49:13 -06:00
parent 75290a3ea0
commit 41b73abf40
2 changed files with 14 additions and 4 deletions

View File

@@ -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) {
@@ -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;

View File

@@ -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);
@@ -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();
@@ -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);
});
@@ -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);