Angular and non-angular NavController working

This commit is contained in:
Max Lynch
2013-09-19 15:06:08 -05:00
parent 4caa67d722
commit 81f8bd811c
4 changed files with 35 additions and 25 deletions

View File

View File

@ -4,11 +4,18 @@ describe('TabBarController', function() {
beforeEach(function() { beforeEach(function() {
var tabEl = $('<div class="tabs"></div>'); var tabEl = $('<div class="tabs"></div>');
ctrl = new TabBarController({ ctrl = new TabBarController({
tabBar: new TabBar({ el: tabEl.get(0) }) tabBar: new TabBar({
el: tabEl.get(0),
itemAdded: function(item) {
},
itemRemoved: function(item) {
}
})
}); });
}) })
it('Should add Controllers', function() { it('Should add Controllers', function() {
debugger;
ctrl.addController({ ctrl.addController({
title: 'Item 1', title: 'Item 1',
icon: 'icon-home', icon: 'icon-home',

View File

View File

@ -27,26 +27,38 @@
<script> <script>
// Grab the sections // Grab the sections
var navBar = document.getElementById('nav-bar'); var navBar = document.getElementById('nav-bar');
var cd = document.getElementById('content');
var View = function(opts) {
this.el = opts.el;
};
var content = new View({
el: cd
});
var controller = function(opts) { var controller = function(opts) {
this.el = opts.el; this.el = opts.el;
} }
controller.prototype = { controller.prototype = {
detach: function() { visibilityChanged: function() {
//this.el.style.display = 'none'; if(this.isVisible) {
var parentNode = this.el.parentNode; //this.el.style.display = 'block';
if(!parentNode) { if(this._lastNodeSpot) {
return; this._lastNodeParent.insertBefore(this.el, this._lastNodeSpot);
} } else {
var next = this.el.nextSibling; content.el.appendChild(this.el);
this._lastNodeSpot = next; }
this._lastNodeParent = parentNode; } else {
parentNode.removeChild(this.el); //this.el.style.display = 'none';
}, var parentNode = this.el.parentNode;
attach: function() { if(!parentNode) {
//this.el.style.display = 'block'; return;
if(this._lastNodeSpot) { }
this._lastNodeParent.insertBefore(this.el, this._lastNodeSpot); var next = this.el.nextSibling;
this._lastNodeSpot = next;
this._lastNodeParent = parentNode;
parentNode.removeChild(this.el);
} }
} }
}; };
@ -61,10 +73,6 @@
return c; return c;
}; };
var View = function(opts) {
this.el = opts.el;
};
var page1 = createPage('Home'); var page1 = createPage('Home');
var page2 = createPage('About'); var page2 = createPage('About');
var page3 = createPage('Cats'); var page3 = createPage('Cats');
@ -72,11 +80,6 @@
var pages = [page1, page2, page3, page4]; var pages = [page1, page2, page3, page4];
var cd = document.getElementById('content');
var content = new View({
el: cd
});
var c = new NavController({ var c = new NavController({
navBar: new NavBar({ el: navBar }), navBar: new NavBar({ el: navBar }),
content: content content: content