mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 06:57:02 +08:00
Toderp signup and nav controller fixes
This commit is contained in:
25
dist/ionic-angular.js
vendored
25
dist/ionic-angular.js
vendored
@ -68,6 +68,12 @@ angular.module('ionic.ui.nav', ['ionic.service'])
|
|||||||
navBar: {
|
navBar: {
|
||||||
shouldGoBack: function() {
|
shouldGoBack: function() {
|
||||||
},
|
},
|
||||||
|
show: function() {
|
||||||
|
this.isVisible = true;
|
||||||
|
},
|
||||||
|
hide: function() {
|
||||||
|
this.isVisible = false;
|
||||||
|
},
|
||||||
setTitle: function(title) {
|
setTitle: function(title) {
|
||||||
$scope.navController.title = title;
|
$scope.navController.title = title;
|
||||||
},
|
},
|
||||||
@ -101,15 +107,16 @@ angular.module('ionic.ui.nav', ['ionic.service'])
|
|||||||
.directive('navBar', function() {
|
.directive('navBar', function() {
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
require: '^navController',
|
require: '^navCtrl',
|
||||||
transclude: true,
|
transclude: true,
|
||||||
replace: true,
|
replace: true,
|
||||||
scope: true,
|
scope: true,
|
||||||
template: '<header class="bar bar-header bar-dark nav-bar" ng-class="{hidden: isHidden}">' +
|
template: '<header class="bar bar-header bar-dark nav-bar" ng-class="{hidden: !navController.navBar.isVisible}">' +
|
||||||
'<a href="#" ng-click="goBack()" class="button" ng-if="controllers.length > 1">Back</a>' +
|
'<a href="#" ng-click="goBack()" class="button" ng-if="navController.controllers.length > 1">Back</a>' +
|
||||||
'<h1 class="title">{{getTopController().title}}</h1>' +
|
'<h1 class="title">{{navController.getTopController().title}}</h1>' +
|
||||||
'</header>',
|
'</header>',
|
||||||
link: function(scope, element, attrs, navCtrl) {
|
link: function(scope, element, attrs, navCtrl) {
|
||||||
|
scope.navController = navCtrl;
|
||||||
scope.goBack = function() {
|
scope.goBack = function() {
|
||||||
navCtrl.pop();
|
navCtrl.pop();
|
||||||
}
|
}
|
||||||
@ -120,9 +127,17 @@ angular.module('ionic.ui.nav', ['ionic.service'])
|
|||||||
.directive('navContent', function() {
|
.directive('navContent', function() {
|
||||||
return {
|
return {
|
||||||
restrict: 'ECA',
|
restrict: 'ECA',
|
||||||
|
require: '^navCtrl',
|
||||||
scope: true,
|
scope: true,
|
||||||
link: function(scope, element, attrs) {
|
link: function(scope, element, attrs, navCtrl) {
|
||||||
scope.title = attrs.title;
|
scope.title = attrs.title;
|
||||||
|
|
||||||
|
if(attrs.navBar === "false") {
|
||||||
|
navCtrl.hideNavBar();
|
||||||
|
} else {
|
||||||
|
navCtrl.showNavBar();
|
||||||
|
}
|
||||||
|
|
||||||
scope.isVisible = true;
|
scope.isVisible = true;
|
||||||
scope.pushController(scope);
|
scope.pushController(scope);
|
||||||
|
|
||||||
|
|||||||
54
dist/ionic.js
vendored
54
dist/ionic.js
vendored
@ -2119,6 +2119,16 @@ ionic.views.TabBar.prototype = {
|
|||||||
;
|
;
|
||||||
(function(ionic) {
|
(function(ionic) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The NavController makes it easy to have a stack
|
||||||
|
* of views or screens that can be pushed and popped
|
||||||
|
* for a dynamic navigation flow. This API is modelled
|
||||||
|
* off of the UINavigationController in iOS.
|
||||||
|
*
|
||||||
|
* The NavController can drive a nav bar to show a back button
|
||||||
|
* if the stack can be poppped to go back to the last view, and
|
||||||
|
* it will handle updating the title of the nav bar and processing animations.
|
||||||
|
*/
|
||||||
ionic.controllers.NavController = function(opts) {
|
ionic.controllers.NavController = function(opts) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
@ -2135,12 +2145,26 @@ ionic.controllers.NavController = function(opts) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ionic.controllers.NavController.prototype = {
|
ionic.controllers.NavController.prototype = {
|
||||||
|
/**
|
||||||
|
* @return {array} the array of controllers on the stack.
|
||||||
|
*/
|
||||||
getControllers: function() {
|
getControllers: function() {
|
||||||
return this.controllers;
|
return this.controllers;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {object} the controller at the top of the stack.
|
||||||
|
*/
|
||||||
getTopController: function() {
|
getTopController: function() {
|
||||||
return this.controllers[this.controllers.length-1];
|
return this.controllers[this.controllers.length-1];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Push a new controller onto the navigation stack. The new controller
|
||||||
|
* will automatically become the new visible view.
|
||||||
|
*
|
||||||
|
* @param {object} controller the controller to push on the stack.
|
||||||
|
*/
|
||||||
push: function(controller) {
|
push: function(controller) {
|
||||||
var last = this.controllers[this.controllers.length - 1];
|
var last = this.controllers[this.controllers.length - 1];
|
||||||
|
|
||||||
@ -2175,6 +2199,12 @@ ionic.controllers.NavController.prototype = {
|
|||||||
return controller;
|
return controller;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pop the top controller off the stack, and show the last one. This is the
|
||||||
|
* "back" operation.
|
||||||
|
*
|
||||||
|
* @return {object} the last popped controller
|
||||||
|
*/
|
||||||
pop: function() {
|
pop: function() {
|
||||||
var next, last;
|
var next, last;
|
||||||
|
|
||||||
@ -2207,8 +2237,27 @@ ionic.controllers.NavController.prototype = {
|
|||||||
return last;
|
return last;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the NavBar (if any)
|
||||||
|
*/
|
||||||
|
showNavBar: function() {
|
||||||
|
if(this.navBar) {
|
||||||
|
this.navBar.show();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide the NavBar (if any)
|
||||||
|
*/
|
||||||
|
hideNavBar: function() {
|
||||||
|
if(this.navBar) {
|
||||||
|
this.navBar.hide();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Update the nav bar after a push or pop
|
||||||
_updateNavBar: function() {
|
_updateNavBar: function() {
|
||||||
if(!this.getTopController()) {
|
if(!this.getTopController() || !this.navBar) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2219,8 +2268,7 @@ ionic.controllers.NavController.prototype = {
|
|||||||
} else {
|
} else {
|
||||||
this.navBar.showBackButton(false);
|
this.navBar.showBackButton(false);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
})(window.ionic);
|
})(window.ionic);
|
||||||
;
|
;
|
||||||
|
|||||||
@ -18,3 +18,11 @@
|
|||||||
}
|
}
|
||||||
#splash-view .ionic-logo {
|
#splash-view .ionic-logo {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#signup-bottom {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|||||||
@ -32,27 +32,82 @@
|
|||||||
|
|
||||||
<!-- The root view controller -->
|
<!-- The root view controller -->
|
||||||
<nav-ctrl ng-controller="TodoCtrl">
|
<nav-ctrl ng-controller="TodoCtrl">
|
||||||
|
<nav-bar></nav-bar>
|
||||||
</nav-ctrl>
|
</nav-ctrl>
|
||||||
|
|
||||||
<!-- Splash -->
|
<!-- Splash -->
|
||||||
<script id="splash.html" type="text/ng-template">
|
<script id="splash.html" type="text/ng-template">
|
||||||
<div id="splash-view" class="view fade-in" nav-content>
|
<div id="splash-view" class="view fade-in" nav-content nav-bar="false">
|
||||||
<img src="img/ionic.png" class="ionic-logo">
|
<img src="img/ionic.png" class="ionic-logo">
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- Login -->
|
|
||||||
<script id="login.html" type="text/ng-template">
|
|
||||||
<div id="login-view" class="view" nav-content ng-controller="LoginCtrl">
|
|
||||||
<h1>Login</h1>
|
|
||||||
</div>
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<!-- Signup -->
|
<!-- Signup -->
|
||||||
<script id="signup.html" type="text/ng-template">
|
<script id="signup.html" type="text/ng-template">
|
||||||
<div id="signup-view" class="view" nav-content ng-controller="SignupCtrl"></div>
|
<div title="Sign up" id="signup-view" class="view" nav-content ng-controller="SignupCtrl"></div>
|
||||||
|
<main class="content">
|
||||||
|
<form class="form-horizontal" ng-submit="trySignup(signupForm)">
|
||||||
|
<div class="container" style="text-align: center">
|
||||||
|
<h1>Toderp</h1>
|
||||||
|
<h4>What do you need to derp?</h4>
|
||||||
|
</div>
|
||||||
|
<div class="input-group">
|
||||||
|
<label class="input-wrapper row">
|
||||||
|
<span class="input-label col-xs-4">Full name</span>
|
||||||
|
<input class="col-xs-8" type="text" placeholder="" ng-model="signupForm.name">
|
||||||
|
</label>
|
||||||
|
<label class="input-wrapper row">
|
||||||
|
<span class="input-label col-xs-4">Email</span>
|
||||||
|
<input class="col-xs-8" type="email" placeholder="" ng-model="signupForm.email">
|
||||||
|
</label>
|
||||||
|
<label class="input-wrapper row">
|
||||||
|
<span class="input-label col-xs-4">Password</span>
|
||||||
|
<input class="col-xs-8" type="password" placeholder="" ng-model="signupForm.password">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="input-group">
|
||||||
|
<button class="button button-primary button-block">Get derp'n</button>
|
||||||
|
<div id="signup-error" ng-show="signupError">Unable to signup, please try again.</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div id="signup-bottom">
|
||||||
|
<h3>Already have an account?</h3>
|
||||||
|
<button class="button button-clear button-block">Sign in</button>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<!-- Login -->
|
||||||
|
<script id="login.html" type="text/ng-template">
|
||||||
|
<div title="Login" id="login-view" class="view" nav-content ng-controller="LoginCtrl">
|
||||||
|
<main class="content padded">
|
||||||
|
<form class="form-horizontal" ng-submit="tryLogin(loginForm)">
|
||||||
|
<div class="input-group inset">
|
||||||
|
<label class="input-wrapper row">
|
||||||
|
<span class="input-label col-xs-4">Full name</span>
|
||||||
|
<input class="col-xs-8" type="text" placeholder="" ng-model="loginForm.name">
|
||||||
|
</label>
|
||||||
|
<label class="input-wrapper row">
|
||||||
|
<span class="input-label col-xs-4">Email</span>
|
||||||
|
<input class="col-xs-8" type="email" placeholder="" ng-model="loginForm.email">
|
||||||
|
</label>
|
||||||
|
<label class="input-wrapper row">
|
||||||
|
<span class="input-label col-xs-4">Password</span>
|
||||||
|
<input class="col-xs-8" type="password" placeholder="" ng-model="loginForm.password">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="input-group inset">
|
||||||
|
<button class="button button-primary button-block">Log in</button>
|
||||||
|
<div id="login-error" ng-show="loginError">Invalid email/password. Please try again.</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<button ng-click="showSignup()" id="signup-button" class="button button-default button-block">Create an account</button>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<!-- Tasks -->
|
<!-- Tasks -->
|
||||||
<script id="tasks.html" type="text/ng-template">
|
<script id="tasks.html" type="text/ng-template">
|
||||||
<side-menu-ctrl id="tasks-view" nav-content class="view" ng-controller="TasksCtrl">
|
<side-menu-ctrl id="tasks-view" nav-content class="view" ng-controller="TasksCtrl">
|
||||||
|
|||||||
@ -5,22 +5,21 @@ angular.module('ionic.todo.controllers', ['ionic.todo', 'firebase'])
|
|||||||
$scope.candy = 'yes';
|
$scope.candy = 'yes';
|
||||||
|
|
||||||
$scope.navController.pushFromTemplate('splash.html');
|
$scope.navController.pushFromTemplate('splash.html');
|
||||||
//$scope.navController.pushFromTemplate('login.html');
|
|
||||||
//$scope.navController.pushFromTemplate('signup.html');
|
|
||||||
//$scope.navController.pushFromTemplate('tasks.html');
|
|
||||||
|
|
||||||
console.log($scope);
|
|
||||||
$rootScope.$on('angularFireAuth:login', function(evt, user) {
|
$rootScope.$on('angularFireAuth:login', function(evt, user) {
|
||||||
$scope.display.screen = 'tasks';
|
$scope.navController.pushFromTemplate('tasks.html');
|
||||||
});
|
});
|
||||||
$rootScope.$on('angularFireAuth:logout', function(evt, user) {
|
$rootScope.$on('angularFireAuth:logout', function(evt, user) {
|
||||||
console.log('Logged out!', evt, user);
|
$scope.navController.pushFromTemplate('signup.html');
|
||||||
});
|
});
|
||||||
$rootScope.$on('angularFireAuth:error', function(evt, err) {
|
$rootScope.$on('angularFireAuth:error', function(evt, err) {
|
||||||
console.log('Login Error!', evt, err);
|
$scope.navController.pushFromTemplate('signup.html');
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
.controller('SplashCtrl', function($scope) {
|
||||||
|
})
|
||||||
|
|
||||||
// The login form controller
|
// The login form controller
|
||||||
.controller('LoginCtrl', function($scope, AuthService) {
|
.controller('LoginCtrl', function($scope, AuthService) {
|
||||||
console.log('Created login Ctrl');
|
console.log('Created login Ctrl');
|
||||||
@ -30,6 +29,10 @@ angular.module('ionic.todo.controllers', ['ionic.todo', 'firebase'])
|
|||||||
password: 'test'
|
password: 'test'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.showSignup = function() {
|
||||||
|
$scope.navController.pushFromTemplate('signup.html');
|
||||||
|
};
|
||||||
|
|
||||||
$scope.tryLogin = function(data) {
|
$scope.tryLogin = function(data) {
|
||||||
$scope.loginError = false;
|
$scope.loginError = false;
|
||||||
AuthService.login(data.email, data.password)
|
AuthService.login(data.email, data.password)
|
||||||
|
|||||||
@ -118,6 +118,24 @@ ionic.controllers.NavController.prototype = {
|
|||||||
return last;
|
return last;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the NavBar (if any)
|
||||||
|
*/
|
||||||
|
showNavBar: function() {
|
||||||
|
if(this.navBar) {
|
||||||
|
this.navBar.show();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide the NavBar (if any)
|
||||||
|
*/
|
||||||
|
hideNavBar: function() {
|
||||||
|
if(this.navBar) {
|
||||||
|
this.navBar.hide();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// Update the nav bar after a push or pop
|
// Update the nav bar after a push or pop
|
||||||
_updateNavBar: function() {
|
_updateNavBar: function() {
|
||||||
if(!this.getTopController() || !this.navBar) {
|
if(!this.getTopController() || !this.navBar) {
|
||||||
|
|||||||
25
js/ext/angular/src/directive/ionicNav.js
vendored
25
js/ext/angular/src/directive/ionicNav.js
vendored
@ -24,6 +24,12 @@ angular.module('ionic.ui.nav', ['ionic.service'])
|
|||||||
navBar: {
|
navBar: {
|
||||||
shouldGoBack: function() {
|
shouldGoBack: function() {
|
||||||
},
|
},
|
||||||
|
show: function() {
|
||||||
|
this.isVisible = true;
|
||||||
|
},
|
||||||
|
hide: function() {
|
||||||
|
this.isVisible = false;
|
||||||
|
},
|
||||||
setTitle: function(title) {
|
setTitle: function(title) {
|
||||||
$scope.navController.title = title;
|
$scope.navController.title = title;
|
||||||
},
|
},
|
||||||
@ -57,15 +63,16 @@ angular.module('ionic.ui.nav', ['ionic.service'])
|
|||||||
.directive('navBar', function() {
|
.directive('navBar', function() {
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
require: '^navController',
|
require: '^navCtrl',
|
||||||
transclude: true,
|
transclude: true,
|
||||||
replace: true,
|
replace: true,
|
||||||
scope: true,
|
scope: true,
|
||||||
template: '<header class="bar bar-header bar-dark nav-bar" ng-class="{hidden: isHidden}">' +
|
template: '<header class="bar bar-header bar-dark nav-bar" ng-class="{hidden: !navController.navBar.isVisible}">' +
|
||||||
'<a href="#" ng-click="goBack()" class="button" ng-if="controllers.length > 1">Back</a>' +
|
'<a href="#" ng-click="goBack()" class="button" ng-if="navController.controllers.length > 1">Back</a>' +
|
||||||
'<h1 class="title">{{getTopController().title}}</h1>' +
|
'<h1 class="title">{{navController.getTopController().title}}</h1>' +
|
||||||
'</header>',
|
'</header>',
|
||||||
link: function(scope, element, attrs, navCtrl) {
|
link: function(scope, element, attrs, navCtrl) {
|
||||||
|
scope.navController = navCtrl;
|
||||||
scope.goBack = function() {
|
scope.goBack = function() {
|
||||||
navCtrl.pop();
|
navCtrl.pop();
|
||||||
}
|
}
|
||||||
@ -76,9 +83,17 @@ angular.module('ionic.ui.nav', ['ionic.service'])
|
|||||||
.directive('navContent', function() {
|
.directive('navContent', function() {
|
||||||
return {
|
return {
|
||||||
restrict: 'ECA',
|
restrict: 'ECA',
|
||||||
|
require: '^navCtrl',
|
||||||
scope: true,
|
scope: true,
|
||||||
link: function(scope, element, attrs) {
|
link: function(scope, element, attrs, navCtrl) {
|
||||||
scope.title = attrs.title;
|
scope.title = attrs.title;
|
||||||
|
|
||||||
|
if(attrs.navBar === "false") {
|
||||||
|
navCtrl.hideNavBar();
|
||||||
|
} else {
|
||||||
|
navCtrl.showNavBar();
|
||||||
|
}
|
||||||
|
|
||||||
scope.isVisible = true;
|
scope.isVisible = true;
|
||||||
scope.pushController(scope);
|
scope.pushController(scope);
|
||||||
|
|
||||||
|
|||||||
@ -40,12 +40,12 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<nav-controller>
|
<nav-ctrl>
|
||||||
<nav-bar></nav-bar>
|
<nav-bar></nav-bar>
|
||||||
|
|
||||||
<content has-header="true" ng-controller="AppCtrl" class="reveal-animation">
|
<content has-header="true" ng-controller="AppCtrl" class="reveal-animation">
|
||||||
</content>
|
</content>
|
||||||
</nav-controller>
|
</nav-ctrl>
|
||||||
|
|
||||||
<script src="../../../../dist/ionic.js"></script>
|
<script src="../../../../dist/ionic.js"></script>
|
||||||
<script src="../../../../dist/ionic-angular.js"></script>
|
<script src="../../../../dist/ionic-angular.js"></script>
|
||||||
@ -64,7 +64,7 @@
|
|||||||
'</div>')(childScope, cb);
|
'</div>')(childScope, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
angular.module('navTest', ['ionic.ui'])
|
angular.module('navTest', ['ionic.ui.nav'])
|
||||||
|
|
||||||
.controller('AppCtrl', function($scope, $compile, $element) {
|
.controller('AppCtrl', function($scope, $compile, $element) {
|
||||||
pushIt($scope, $compile, $element, function(cloned, scope) {
|
pushIt($scope, $compile, $element, function(cloned, scope) {
|
||||||
|
|||||||
Reference in New Issue
Block a user