Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pec1985
Created June 13, 2011 17:43
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pec1985/1023281 to your computer and use it in GitHub Desktop.
Save pec1985/1023281 to your computer and use it in GitHub Desktop.
Simple Single-Context app
// namespace for the windows
var W = {};
// namespace for custom UI
var UI = {};
// store the tabs in this array for later use
var tabs = [];
// include the necessary files to run the app
Ti.include('ui.js');
Ti.include('other.js');
Ti.include('window1.js');
Ti.include('window2.js');
Ti.include('tabgroup.js');
W.TabGroup().open();
W.OtherWin = function(){
var win = UI.Win();
var label = Ti.UI.createLabel({
backgroundColor:'purple',
color:'black',
text:'this is another window',
width:'auto',
height:'auto'
});
win.add(label);
return win;
}
W.TabGroup = function(){
var tabGroup = Ti.UI.createTabGroup();
tabs[0] = Ti.UI.createTab({
window:W.Window1(),
title:'green'
});
tabs[1] = Ti.UI.createTab({
window:W.Window2(),
title:'blue'
});
tabGroup.addTab(tabs[0]);
tabGroup.addTab(tabs[1]);
return tabGroup;
};
UI.Win = function(a){
a = a || {};
var win = Ti.UI.createWindow(a);
win.orientationModes = [1,2,3,4];
return win;
}
W.Window1 = function(){
var win = UI.Win({
backgroundColor:'#999'
});
var button = Ti.UI.createButton({
backgroundColor:'green',
color:'black',
title:'this is window 1',
width:100,
height:40
});
button.addEventListener('click', function(){
tabs[0].open(W.OtherWin());
});
win.add(button);
return win;
};
W.Window2 = function(){
var win = UI.Win();
var label = Ti.UI.createLabel({
backgroundColor:'blue',
color:'black',
text:'this is window 2',
width:'auto',
height:'auto'
});
win.add(label);
return win;
}
@snout-o
Copy link

snout-o commented Jun 28, 2011

Should there not be a

return win;

on Window1.js?

@pec1985
Copy link
Author

pec1985 commented Jun 28, 2011

Yes, sorry. It's fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment