Created
June 13, 2011 17:43
-
-
Save pec1985/1023281 to your computer and use it in GitHub Desktop.
Simple Single-Context app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UI.Win = function(a){ | |
a = a || {}; | |
var win = Ti.UI.createWindow(a); | |
win.orientationModes = [1,2,3,4]; | |
return win; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should there not be a
return win;
on Window1.js?