mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix view hideNavBar attribute, closes #394
This commit is contained in:
12
dist/js/ionic-angular.js
vendored
12
dist/js/ionic-angular.js
vendored
@@ -2508,7 +2508,7 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
|
||||
backButtonIcon: '@',
|
||||
alignTitle: '@'
|
||||
},
|
||||
template: '<header class="bar bar-header nav-bar">'+//' ng-class="{invisible: !navController.navBar.isVisible}">' +
|
||||
template: '<header class="bar bar-header nav-bar" ng-class="{invisible: !showNavBar}">' +
|
||||
'<div class="buttons"> ' +
|
||||
'<button view-back class="button" ng-if="enableBackButton" ng-class="backButtonClass" ng-bind-html="backButtonLabel"></button>' +
|
||||
'<button ng-click="button.tap($event)" ng-repeat="button in leftButtons" class="button no-animation {{button.type}}" ng-bind-html="button.content"></button>' +
|
||||
@@ -2518,7 +2518,7 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
|
||||
'<button ng-click="button.tap($event)" ng-repeat="button in rightButtons" class="button no-animation {{button.type}}" ng-bind-html="button.content"></button>' +
|
||||
'</div>' +
|
||||
'</header>',
|
||||
link: function($scope, $element, $attr, navCtrl) {
|
||||
link: function($scope, $element, $attr) {
|
||||
|
||||
// Create the back button content and show/hide it based on scope settings
|
||||
$scope.enableBackButton = true;
|
||||
@@ -2527,8 +2527,10 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
|
||||
$scope.backButtonClass += ' icon ' + $attr.backButtonIcon;
|
||||
}
|
||||
|
||||
// Store a reference to our nav controller
|
||||
$scope.navController = navCtrl;
|
||||
$scope.showNavBar = true;
|
||||
$rootScope.$on('viewState.showNavBar', function(e, data) {
|
||||
$scope.showNavBar = data;
|
||||
});
|
||||
|
||||
// Initialize our header bar view which will handle resizing and aligning our title labels
|
||||
var hb = new ionic.views.HeaderBar({
|
||||
@@ -2619,7 +2621,9 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
|
||||
$rootScope.$broadcast('viewState.showBackButton', false);
|
||||
}
|
||||
|
||||
// Should the nav bar be hidden for this view or not?
|
||||
$scope.hideNavBar = $scope.$eval($scope.hideNavBar);
|
||||
$rootScope.$broadcast('viewState.showNavBar', !$scope.hideNavBar);
|
||||
|
||||
// watch for changes in the left buttons
|
||||
$scope.$watch('leftButtons', function(value) {
|
||||
|
||||
2
dist/js/ionic-angular.min.js
vendored
2
dist/js/ionic-angular.min.js
vendored
File diff suppressed because one or more lines are too long
12
js/ext/angular/src/directive/ionicViewState.js
vendored
12
js/ext/angular/src/directive/ionicViewState.js
vendored
@@ -67,7 +67,7 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
|
||||
backButtonIcon: '@',
|
||||
alignTitle: '@'
|
||||
},
|
||||
template: '<header class="bar bar-header nav-bar">'+//' ng-class="{invisible: !navController.navBar.isVisible}">' +
|
||||
template: '<header class="bar bar-header nav-bar" ng-class="{invisible: !showNavBar}">' +
|
||||
'<div class="buttons"> ' +
|
||||
'<button view-back class="button" ng-if="enableBackButton" ng-class="backButtonClass" ng-bind-html="backButtonLabel"></button>' +
|
||||
'<button ng-click="button.tap($event)" ng-repeat="button in leftButtons" class="button no-animation {{button.type}}" ng-bind-html="button.content"></button>' +
|
||||
@@ -77,7 +77,7 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
|
||||
'<button ng-click="button.tap($event)" ng-repeat="button in rightButtons" class="button no-animation {{button.type}}" ng-bind-html="button.content"></button>' +
|
||||
'</div>' +
|
||||
'</header>',
|
||||
link: function($scope, $element, $attr, navCtrl) {
|
||||
link: function($scope, $element, $attr) {
|
||||
|
||||
// Create the back button content and show/hide it based on scope settings
|
||||
$scope.enableBackButton = true;
|
||||
@@ -86,8 +86,10 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
|
||||
$scope.backButtonClass += ' icon ' + $attr.backButtonIcon;
|
||||
}
|
||||
|
||||
// Store a reference to our nav controller
|
||||
$scope.navController = navCtrl;
|
||||
$scope.showNavBar = true;
|
||||
$rootScope.$on('viewState.showNavBar', function(e, data) {
|
||||
$scope.showNavBar = data;
|
||||
});
|
||||
|
||||
// Initialize our header bar view which will handle resizing and aligning our title labels
|
||||
var hb = new ionic.views.HeaderBar({
|
||||
@@ -178,7 +180,9 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
|
||||
$rootScope.$broadcast('viewState.showBackButton', false);
|
||||
}
|
||||
|
||||
// Should the nav bar be hidden for this view or not?
|
||||
$scope.hideNavBar = $scope.$eval($scope.hideNavBar);
|
||||
$rootScope.$broadcast('viewState.showNavBar', !$scope.hideNavBar);
|
||||
|
||||
// watch for changes in the left buttons
|
||||
$scope.$watch('leftButtons', function(value) {
|
||||
|
||||
@@ -42,7 +42,30 @@ describe('Ionic View', function() {
|
||||
expect(element.hasClass('hide')).toEqual(false);
|
||||
scope.$broadcast('$viewHistory.historyChange', { showBack: false });
|
||||
expect(element.hasClass('hide')).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should show/hide navBar', function() {
|
||||
var element = compile('<nav-bar></nav-bar>')(scope);
|
||||
expect(element.hasClass('invisible')).toEqual(false);
|
||||
scope.$broadcast('viewState.showNavBar', false);
|
||||
scope.$digest();
|
||||
expect(element.hasClass('invisible')).toEqual(true);
|
||||
scope.$broadcast('viewState.showNavBar', true);
|
||||
scope.$digest();
|
||||
expect(element.hasClass('invisible')).toEqual(false);
|
||||
});
|
||||
|
||||
it('should hide navBar when using view attr', function() {
|
||||
var element = compile('<div><nav-bar></nav-bar><view hide-nav-bar="true"></view></div>')(scope);
|
||||
scope.$digest();
|
||||
var navBar = element.find('header')
|
||||
expect(navBar.hasClass('invisible')).toEqual(true);
|
||||
|
||||
element = compile('<div><nav-bar></nav-bar><view></view></div>')(scope);
|
||||
scope.$digest();
|
||||
navBar = element.find('header')
|
||||
expect(navBar.hasClass('invisible')).toEqual(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -58,10 +58,13 @@
|
||||
</script>
|
||||
|
||||
<script id="forgot-password.html" type="text/ng-template">
|
||||
<view title="'Forgot Password'">
|
||||
<view title="'Forgot Password'" hide-nav-bar="true">
|
||||
<content has-header="true" padding="true">
|
||||
<p>Seriously!? Again?!</p>
|
||||
<p>How about I just give you a password, hows this: <br><code>{{password}}</code></p>
|
||||
<p>This view hides the nav bar using the hideNavBar attribute.</p>
|
||||
<p>
|
||||
<button ng-click="hideNavBar()">Hide Nav Bar</button>
|
||||
<button ng-click="showNavBar()">Show Nav Bar</button>
|
||||
</p>
|
||||
<p>
|
||||
<button ng-click="clearViewHistory()">Clear View History</button>
|
||||
</p>
|
||||
@@ -183,7 +186,7 @@
|
||||
<p>
|
||||
<button ng-click="hideBackButton()">Hide Back Button</button>
|
||||
<button ng-click="showBackButton()">Show Back Button</button>
|
||||
</p>
|
||||
</p>
|
||||
<p>
|
||||
Current View: {{ $viewHistory.currentView }}<br>
|
||||
Back View: {{ $viewHistory.backView }}<br>
|
||||
@@ -304,19 +307,23 @@
|
||||
})
|
||||
|
||||
.controller('SignInCtrl', function($scope, $state) {
|
||||
//console.log('SignInCtrl');
|
||||
|
||||
$scope.signIn = function(user) {
|
||||
$state.go('tabs.autolist');
|
||||
};
|
||||
})
|
||||
|
||||
.controller('ForgotPasswordCtrl', function(ViewService, $scope, $state) {
|
||||
$scope.password = Math.round(Math.random() * 10000);
|
||||
|
||||
.controller('ForgotPasswordCtrl', function(ViewService, $rootScope, $scope, $state) {
|
||||
$scope.clearViewHistory = function() {
|
||||
ViewService.clearHistory();
|
||||
};
|
||||
|
||||
$scope.hideNavBar = function() {
|
||||
$rootScope.$broadcast('viewState.showNavBar', false);
|
||||
};
|
||||
|
||||
$scope.showNavBar = function() {
|
||||
$rootScope.$broadcast('viewState.showNavBar', true);
|
||||
};
|
||||
})
|
||||
|
||||
.controller('AutoListCtrl', function($scope, $state) {
|
||||
|
||||
Reference in New Issue
Block a user