Created
September 17, 2012 20:10
-
-
Save Mindelusions/3739491 to your computer and use it in GitHub Desktop.
Simple Titanium Commonjs Example
This file contains 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
var MainWindow = require('MainWindow'); | |
var mainWin = new MainWindow(); | |
mainWin.open(); |
This file contains 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
function BarWindow() { | |
var self = Ti.UI.createWindow({ | |
backgroundColor:'#f0f0f0', | |
layout:'vertical' | |
}); | |
var lbl = Ti.UI.createLabel({ | |
text:'Bar Window', | |
color:'#000', | |
top:20 | |
}); | |
lbl.addEventListener('click', function() { | |
self.close(); | |
}); | |
self.add(lbl); | |
var btnFoo = Ti.UI.createButton({ | |
title:'Open FooWindow', | |
top:25 | |
}); | |
btnFoo.addEventListener('click', function() { | |
var FooWindow = require('FooWindow'); | |
var fooWin = new FooWindow(); | |
fooWin.open(); | |
}); | |
self.add(btnFoo); | |
return self; | |
}; | |
module.exports = BarWindow; |
This file contains 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
function FooWindow() { | |
var self = Ti.UI.createWindow({ | |
backgroundColor:'#dfdfdf', | |
layout:'vertical' | |
}); | |
var lbl = Ti.UI.createLabel({ | |
text:'Foo Window', | |
color:'#000', | |
top:20 | |
}); | |
lbl.addEventListener('click', function() { | |
self.close(); | |
}); | |
self.add(lbl); | |
var btnBar = Ti.UI.createButton({ | |
title:'Open BarWindow', | |
top:25 | |
}); | |
btnBar.addEventListener('click', function() { | |
var BarWindow = require('BarWindow'); | |
var barWin = new BarWindow(); | |
barWin.open(); | |
}); | |
self.add(btnBar); | |
return self; | |
}; | |
module.exports = FooWindow; |
This file contains 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
function MainWindow() { | |
var self = Ti.UI.createWindow({ | |
backgroundColor:'#fff', | |
layout:'vertical' | |
}); | |
var lbl = Ti.UI.createLabel({ | |
text:'Main Window', | |
color:'#000', | |
top:'20' | |
}); | |
self.add(lbl); | |
var btnFoo = Ti.UI.createButton({ | |
title:'Open FooWindow', | |
top:25 | |
}); | |
btnFoo.addEventListener('click', function() { | |
var FooWindow = require('FooWindow'); | |
var fooWin = new FooWindow(); | |
fooWin.open(); | |
}); | |
self.add(btnFoo); | |
var btnBar = Ti.UI.createButton({ | |
title:'Open BarWindow', | |
top:25 | |
}); | |
btnBar.addEventListener('click', function() { | |
var BarWindow = require('BarWindow'); | |
var barWin = new BarWindow(); | |
barWin.open(); | |
}); | |
self.add(btnBar); | |
return self; | |
}; | |
module.exports = MainWindow; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment