fix(headerBar): pass attrs from ionNavBar

Closes #2563
This commit is contained in:
Adam Bradley
2014-11-18 09:30:14 -06:00
parent 6276506d4f
commit 48726297d9
2 changed files with 27 additions and 2 deletions

View File

@@ -47,8 +47,10 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
var containerEle = jqLite('<div class="nav-bar-block">');
ionic.DomUtil.cachedAttr(containerEle, 'nav-bar', isActive ? 'active' : 'cached');
var headerBarEle = jqLite('<ion-header-bar>').addClass($attrs.class);
var titleEle = jqLite('<div class="title title-' + $ionicConfig.navBar.alignTitle() + '">');
var alignTitle = $attrs.alignTitle || $ionicConfig.navBar.alignTitle();
var headerBarEle = jqLite('<ion-header-bar>').addClass($attrs.class).attr('align-title', alignTitle);
if (isDefined($attrs.noTapScroll)) headerBarEle.attr('no-tap-scroll', $attrs.noTapScroll);
var titleEle = jqLite('<div class="title title-' + alignTitle + '">');
var navEle = {};
var lastViewBtnsEle = {};
var leftButtonsEle, rightButtonsEle;

View File

@@ -110,6 +110,29 @@ describe('ionNavBar', function() {
expect(parentScope.$hasHeader).toBe(false);
});
it('should set header align-title attr from ion-nav-bar', inject(function($ionicConfig) {
$ionicConfig.navBar.alignTitle('left');
var el = setup();
expect(el[0].querySelector('ion-header-bar').getAttribute('align-title')).toEqual('left');
expect(el[0].querySelector('ion-header-bar .title').classList.contains('title-left')).toEqual(true);
el = setup('align-title="right"');
expect(el[0].querySelector('ion-header-bar').getAttribute('align-title')).toEqual('right');
expect(el[0].querySelector('ion-header-bar .title').classList.contains('title-right')).toEqual(true);
}));
it('should set header no-tap-scroll attr from ion-nav-bar', function() {
var el = setup();
expect(el[0].querySelector('ion-header-bar').getAttribute('no-tap-scroll')).toEqual(null);
el = setup('no-tap-scroll="true"');
expect(el[0].querySelector('ion-header-bar').getAttribute('no-tap-scroll')).toEqual('true');
el = setup('no-tap-scroll="false"');
expect(el[0].querySelector('ion-header-bar').getAttribute('no-tap-scroll')).toEqual('false');
});
it('should register with $ionicNavBarDelegate', inject(function($ionicNavBarDelegate) {
var deregisterSpy = jasmine.createSpy('deregister');
spyOn($ionicNavBarDelegate, '_registerInstance').andCallFake(function() {