Skip to content

Instantly share code, notes, and snippets.

@jonalter
Created March 30, 2011 02:31
Show Gist options
  • Save jonalter/893755 to your computer and use it in GitHub Desktop.
Save jonalter/893755 to your computer and use it in GitHub Desktop.
Creating Reusable Factories and Using Namespaces
var myApp = {};
Ti.include('ui.js');
myApp.tabGroup = myApp.ui.createAppTabGroup();
myApp.tabGroup.open();
(function() {
myApp.ui = {};
myApp.ui.createTableWindow = function(_e) {
var win = Ti.UI.createWindow({
title: _e.title,
backgroundColor: _e.backgroundColor
});
return win;
};
myApp.ui.createAppTabGroup = function() {
var tabGroup = Titanium.UI.createTabGroup();
var tab1 = Titanium.UI.createTab({
title: 'Blue',
window: myApp.ui.createTableWindow({
title: 'Blue',
backgroundColor: 'blue'
})
});
var tab2 = Titanium.UI.createTab({
title: 'Red',
window: myApp.ui.createTableWindow({
title: 'Red',
backgroundColor:'red'
})
});
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
return tabGroup;
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment