From 8c26932c7b635f1c3fe9adbe7d39d1ef4162d166 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Tue, 17 Sep 2013 17:03:32 -0500 Subject: [PATCH] Changed TabBar controller to use setVisible This makes it a little more generic and we can easily override this in an Angular controller. --- hacking/TabBarController.js | 6 ++++-- hacking/tabs.html | 31 ++++++++++++++++--------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/hacking/TabBarController.js b/hacking/TabBarController.js index 7fe1776654..011668d368 100644 --- a/hacking/TabBarController.js +++ b/hacking/TabBarController.js @@ -59,11 +59,13 @@ TabBarController.prototype = { for(var i = 0, j = this.controllers.length; i < j; i ++) { c = this.controllers[i]; - c.detach && c.detach(); + //c.detach && c.detach(); + c.setVisible(false); } c = this.controllers[index]; - c.attach && c.attach(); + //c.attach && c.attach(); + c.setVisible(true); }, _clearSelected: function() { diff --git a/hacking/tabs.html b/hacking/tabs.html index 90a687101d..1eb838befc 100644 --- a/hacking/tabs.html +++ b/hacking/tabs.html @@ -76,23 +76,24 @@ this.el = opts.el; } controller.prototype = { - detach: function() { - //this.el.style.display = 'none'; - var parentNode = this.el.parentNode; - if(!parentNode) { - return; + setVisible: function(isVisible) { + if(isVisible) { + //this.el.style.display = 'block'; + if(this._lastNodeSpot) { + this._lastNodeParent.insertBefore(this.el, this._lastNodeSpot); + } + } else { + //this.el.style.display = 'none'; + var parentNode = this.el.parentNode; + if(!parentNode) { + return; + } + var next = this.el.nextSibling; + this._lastNodeSpot = next; + this._lastNodeParent = parentNode; + parentNode.removeChild(this.el); } - var next = this.el.nextSibling; - this._lastNodeSpot = next; - this._lastNodeParent = parentNode; - parentNode.removeChild(this.el); }, - attach: function() { - //this.el.style.display = 'block'; - if(this._lastNodeSpot) { - this._lastNodeParent.insertBefore(this.el, this._lastNodeSpot); - } - } }; var c1 = new controller({