fix(backButton): add .header-item class

Add the .header-item class to each of the root child items of a nav
header bar. This gives CSS more power to state what should and should
not be shown during the different states of a transition, specifically
for iOS nav bar transitions.
This commit is contained in:
Adam Bradley
2014-11-19 12:44:15 -06:00
parent b4e4055a06
commit 57bf4f1683
6 changed files with 15 additions and 6 deletions

View File

@@ -22,7 +22,7 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
var titleRight = 0;
var titleCss = '';
var isBackEnabled = false;
var isBackShown = false;
var isBackShown = true;
var titleTextWidth = 0;
@@ -46,7 +46,7 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
// to the navigation and history
if (arguments.length && shouldEnable !== isBackEnabled) {
var backBtnEle = getEle(BACK_BUTTON);
backBtnEle && backBtnEle.classList[ shouldEnable ? 'remove' : 'add' ](HIDE);
backBtnEle && backBtnEle.classList[ shouldEnable ? 'remove' : 'add' ]('back-disabled');
isBackEnabled = shouldEnable;
}
return isBackEnabled;
@@ -58,7 +58,7 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
// visually hidden if false, even if the history says it should show
if (arguments.length && shouldShow !== isBackShown) {
var backBtnEle = getEle(BACK_BUTTON);
if (backBtnEle) backBtnEle.style.display = (shouldShow ? '' : 'none');
backBtnEle && backBtnEle.classList[ shouldShow ? 'remove' : 'add' ](HIDE);
isBackShown = shouldShow;
}
return isBackShown;
@@ -122,7 +122,6 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
defaultTitleEle.classList.remove(HIDE);
}
}
self.showBack(true);
};

View File

@@ -69,6 +69,11 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
positionButtons(navEle[buttonType], buttonType);
});
// add header-item to the root children
for (var x = 0; x < headerBarEle[0].children.length; x++) {
headerBarEle[0].children[x].classList.add('header-item');
}
// compile header and append to the DOM
containerEle.append(headerBarEle);
$element.append($compile(containerEle)($scope.$new()));