mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-06 22:29:44 +08:00
Nav controller tests
This commit is contained in:
@ -2,10 +2,13 @@
|
||||
NavController = function(opts) {
|
||||
var _this = this;
|
||||
|
||||
console.log('CONSTRUCTOR', this);
|
||||
|
||||
this.navBar = opts.navBar;
|
||||
this.content = opts.content;
|
||||
this.controllers = opts.controllers || [];
|
||||
|
||||
this._updateNavBar();
|
||||
|
||||
// TODO: Is this the best way?
|
||||
this.navBar.shouldGoBack = function() {
|
||||
@ -18,10 +21,12 @@
|
||||
return this.controllers;
|
||||
},
|
||||
getTopController: function() {
|
||||
return this.topController;
|
||||
return this.controllers[this.controllers.length-1];
|
||||
},
|
||||
push: function(controller) {
|
||||
var last = this.topController;
|
||||
console.log('PUSHING');
|
||||
|
||||
var last = this.controllers[this.controllers.length - 1];
|
||||
|
||||
this.controllers.push(controller);
|
||||
|
||||
@ -36,15 +41,17 @@
|
||||
|
||||
// Remove the old one
|
||||
//last && last.detach();
|
||||
if(last) {
|
||||
last.isVisible = false;
|
||||
last.visibilityChanged && last.visibilityChanged();
|
||||
}
|
||||
|
||||
// Grab the top controller on the stack
|
||||
var next = this.controllers[this.controllers.length - 1];
|
||||
|
||||
// TODO: No DOM stuff here
|
||||
//this.content.el.appendChild(next.el);
|
||||
|
||||
// Switch to it (TODO: Animate or such things here)
|
||||
this.topController = next;
|
||||
console.log('Top controller modified', this.topController);
|
||||
|
||||
this._updateNavBar();
|
||||
|
||||
@ -72,6 +79,7 @@
|
||||
|
||||
// Switch to it (TODO: Animate or such things here)
|
||||
this.topController = next;
|
||||
console.log('Top controller modified', this.topController);
|
||||
|
||||
this._updateNavBar();
|
||||
|
||||
@ -79,6 +87,10 @@
|
||||
},
|
||||
|
||||
_updateNavBar: function() {
|
||||
if(!this.topController) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.navBar.setTitle(this.topController.title);
|
||||
|
||||
if(this.controllers.length > 1) {
|
||||
|
||||
Reference in New Issue
Block a user