Skip to content

Instantly share code, notes, and snippets.

View jonalter's full-sized avatar

Jonathan Alter jonalter

View GitHub Profile
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
//
// create base UI tab and root window
//
@jonalter
jonalter / app.js
Created March 15, 2011 17:21
TiBountyHunter creating reusable factories
Titanium.UI.setBackgroundColor('#000');
var BHunter = {};
Ti.include('ui.js');
BHunter.tabGroup = BHunter.ui.createAppTabGroup();
BHunter.tabGroup.open();
@jonalter
jonalter / app.js
Created March 16, 2011 16:39
NavigationGroup Example
var win = Titanium.UI.createWindow();
var win1 = Titanium.UI.createWindow({
backgroundColor:"red",
title:"Red Window"
});
var nav = Titanium.UI.iPhone.createNavigationGroup({
window: win1
});
var button = Ti.UI.createButton({
@jonalter
jonalter / app.js
Created March 18, 2011 01:03
Open Show Hide Window
var mainWin = Ti.UI.createWindow({
backgroundColor: 'blue'
});
var win;
var showButton = Ti.UI.createButton({
title: 'show',
height: 60,
width: 200,
top: 80
@jonalter
jonalter / app.js
Created March 18, 2011 19:15
TabGroup in a TabGroup
var tabGroupOuter = Ti.UI.createTabGroup();
tabGroupOuter.addTab(Ti.UI.createTab({
title: 'app.js',
window: Ti.UI.createWindow({
title: 'app.js',
url: 'middle.js',
backgroundColor: 'red'
})
}));
tabGroupOuter.open();
@jonalter
jonalter / app.js
Created March 18, 2011 19:49
android:back event
var mainWin = Ti.UI.createWindow({
backgroundColor: 'blue',
exitOnClose: false,
fullscreen: true
});
mainWin.addEventListener('android:back', function(e) {
Ti.API.info('clicked BACK button');
});
mainWin.open();
@jonalter
jonalter / app.js
Created March 18, 2011 22:18
Programmatic way to close an alert
// Open an existing window
window.open();
// Create the alert dialog popup
var popup = Ti.UI.createAlertDialog({
title: "Confirm Purchase?",
buttonNames: ["Yes", "No"],
cancel: 1
});
@jonalter
jonalter / app.js
Created March 19, 2011 01:04
Filesystem MODE_APPEND
var f = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, 'text.txt');
Ti.API.info('file = ' + f);
var contents = f.read();
Ti.API.info('exists = ' + f.exists());
Ti.API.info("contents blob object = "+contents);
Ti.API.info('contents = ' + contents.text);
var newFile = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory,'newfile.txt');
Ti.API.info('mode: '+ Ti.Filesystem.MODE_APPEND);
newFile.write(f.read());
@jonalter
jonalter / app.js
Created March 29, 2011 21:36
ScrollableView opening custom windows
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
var views = [];
for (var i = 0; i < 10; i++) {
var imgView = Ti.UI.createImageView({
image: 'KS_nav_ui.png',
customData: i+1,
top: 0, left: 0,
width: 100,
height: 50
@jonalter
jonalter / app.js
Created March 30, 2011 02:31
Creating Reusable Factories and Using Namespaces
var myApp = {};
Ti.include('ui.js');
myApp.tabGroup = myApp.ui.createAppTabGroup();
myApp.tabGroup.open();