Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #233 from huaruiwu/backButtonHide
Browse files Browse the repository at this point in the history
Back button hide
  • Loading branch information
paglias committed Jul 28, 2014
2 parents b1f0ce6 + 0a95ed0 commit 392aedb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
20 changes: 18 additions & 2 deletions scripts/controllers/rootCtrl.js
Expand Up @@ -2,8 +2,8 @@

// Make user and settings available for everyone through root scope.
habitrpg.controller('RootCtrl',
['$scope', '$rootScope', '$location', 'User', '$state', '$stateParams', '$window', '$ionicPlatform', 'Groups',
function ($scope, $rootScope, $location, User, $state, $stateParams, $window, $ionicPlatform, Groups) {
['$scope', '$rootScope', '$location', '$ionicNavBarDelegate', 'User', '$state', '$stateParams', '$window', '$ionicPlatform', 'Groups',
function ($scope, $rootScope, $location, $ionicNavBarDelegate, User, $state, $stateParams, $window, $ionicPlatform, Groups) {

$rootScope.User = User;
$rootScope.user = User.user;
Expand Down Expand Up @@ -46,5 +46,21 @@ habitrpg.controller('RootCtrl',
$rootScope.externalLink = function(link){
window.open(link,'_system');
}

$rootScope.goBack = function() {
history.back();
}

$rootScope.getPreviousTitle = function() {
return $ionicNavBarDelegate.getPreviousTitle();
}

$scope.hideBackButton = function() {
var baseRoutes = /^\/app((\/|\/(?!task\/)([a-zA-Z]*)\/)[^\/]+$)/;
if ( baseRoutes.test($location.path()) ) {
return true;
}
return false;
}
}
]);
4 changes: 2 additions & 2 deletions views/app.jade
Expand Up @@ -15,9 +15,9 @@ script(id='views/app.html',type='text/ng-template')
ion-side-menus
ion-pane(ion-side-menu-content)
ion-nav-bar.bar-stable(align-title='left')
ion-nav-back-button.button-clear
.button.button-clear(ng-hide='hideBackButton()' ng-click='goBack()')
i.icon.ion-chevron-left
| Back
| {{getPreviousTitle() || 'Back'}}

ion-nav-view(name='menuContent', animation='slide-left-right')
ion-side-menu(side='left')
Expand Down

0 comments on commit 392aedb

Please sign in to comment.