Skip to content

Instantly share code, notes, and snippets.

@gonz
Created November 30, 2011 00:47
Show Gist options
  • Save gonz/1407416 to your computer and use it in GitHub Desktop.
Save gonz/1407416 to your computer and use it in GitHub Desktop.
diff --git a/app/js/app.js b/app/js/app.js
index c7f8248..0dfc712 100644
--- a/app/js/app.js
+++ b/app/js/app.js
@@ -45,9 +45,24 @@ var HealthyFamily = Ext.extend(Ext.Application, {
*
* Returns nothing
*/
- show: function(obj) {
- this.views.activePanel.items.clear();
- this.views.activePanel.setActiveItem(obj);
+ show: function(newPanel) {
+ var viewportPanel = this.viewport.getActiveItem(),
+ managerPanel;
+
+ if (viewportPanel != 'HealthyFamilyTabPanel') { //XXX: Pseudocode
+ managerPanel = this.viewport;
+ } else {
+ managerPanel = viewportPanel.getActiveItem();;
+ }
+
+ oldPanel = managerPanel.getActiveItem()
+
+ if (oldPanel !== null) {
+ oldPanel.hide();
+ oldPanel.destroy();
+ }
+
+ managerPanel.setActiveItem(newPanel);
},
/* Public: Goes back one level in browser history
@@ -78,32 +93,16 @@ var HealthyFamily = Ext.extend(Ext.Application, {
};
},
- /* Public: Switches current active panel
- *
- * panel - New panel to define as active
- *
- * Returns nothing
- */
- setActivePanel: function(panel) {
- if (typeof this.views.activePanel !== 'undefined') {
- /* Destroy current panel if any */
- this.views.activePanel.hide();
- this.views.activePanel.destroy();
- }
- this.views.activePanel = panel;
- this.views.activePanel.show();
- },
-
/* Public: Lunch application (used by Sencha)
*
* Returns false to avoid an internal redirect on Sencha code.
*/
launch: function() {
- this.setActivePanel(new Ext.Panel({
+ this.viewport = new Ext.Panel({
fullscreen: true,
layout: 'card',
scroll: 'vertical'
- }));
+ });
HealthyFamily.open('/');
/* Return false to avoid further redirects */
diff --git a/app/js/controllers/main.js b/app/js/controllers/main.js
index 94fe183..6007e1b 100644
--- a/app/js/controllers/main.js
+++ b/app/js/controllers/main.js
@@ -6,7 +6,7 @@ Ext.regController('Main', {
}[HealthyFamily.config.user.usertype]
if (typeof Panel !== 'undefined') {
- HealthyFamily.setActivePanel(new Panel());
+ HealthyFamily.show(new Panel());
}
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment