Skip to content

Instantly share code, notes, and snippets.

View jonalter's full-sized avatar

Jonathan Alter jonalter

View GitHub Profile
@jonalter
jonalter / app.js
Created March 30, 2011 03:24
Creating Reusable Factories and Using Ti.App
// Please note that this is a dirty solution.
// It does work, but Appcelerator does not support it (adding things to the Ti namespace).
// There is a very good chance that it will not be possible in future releases.
Ti.include('ui.js');
var win = Ti.App.ui.createCustomWindow();
var button = Ti.App.ui.createCustomButton();
win.add(button);
@jonalter
jonalter / app.js
Created April 4, 2011 22:06
TableView With DB and tap and hold
var win = Ti.UI.createWindow({
backgroundColor: 'white'
});
var tableView = Ti.UI.createTableView();
var setupDB = function() {
var db = Ti.Database.open('mydb.db');
db.execute('CREATE TABLE IF NOT EXISTS DATABASETEST (ID INTEGER, NAME TEXT)');
db.execute('DELETE FROM DATABASETEST');
@jonalter
jonalter / app.js
Created April 11, 2011 21:33
ImageView download changed image, remove cache
var win = Ti.UI.createWindow({
backgroundColor: 'yellow'
});
var imageView = Titanium.UI.createImageView();
win.add(imageView);
imageView.image = 'http://localhost/~jalter/GitApp/images/test.jpg?time='+new Date().getTime();
var button = Ti.UI.createButton({
title: 'click',
@jonalter
jonalter / app.js
Created April 12, 2011 02:30
Facebook post to wall
var win = Ti.UI.createWindow();
Titanium.Facebook.appid = '187692147928682';
Titanium.Facebook.permissions = ['publish_stream'];
Titanium.Facebook.addEventListener('logout', function(e) {
alert('Logged out');
button.title = "Login";
});
Ti.Facebook.addEventListener('login', function(e) {
Ti.API.info("Logged in now!");
@jonalter
jonalter / app.js
Created April 27, 2011 21:24
Camera
Titanium.UI.setBackgroundColor('#000');
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var camera_button = Titanium.UI.createButton ({
title:'Camera',
height:60,
@jonalter
jonalter / app.js
Created May 2, 2011 22:14
Android/iOS tabGroup orientation
Titanium.UI.setBackgroundColor('#000');
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
@jonalter
jonalter / app.js
Created May 3, 2011 17:44
Creating Reusable Factories and Using Ti.App with a Namespace
// Please note that this is a dirty solution.
// It does work, but Appcelerator does not support it (adding things to the Ti namespace).
// There is a very good chance that it will not be possible in future releases.
var ui = {};
var labels = {};
Ti.include('ui.js');
Ti.include('labels.js');
@jonalter
jonalter / app.js
Created May 24, 2011 01:49
currentTab workaround
var tabGroup = Ti.UI.createTabGroup();
var win1 = Ti.UI.createWindow({
title: 'Win 1',
url: 'win1.js'
});
var tab1 = Ti.UI.createTab({
title: 'Tab 1',
window: win1
@jonalter
jonalter / app.js
Created May 27, 2011 00:38
camera with overlay
var win = Ti.UI.createWindow({ fullscreen: true });
var cameraOverlay = Ti.UI.createView();
var cameraButton = Ti.UI.createButton({
title:"Take Picture",
bottom: 10
});
cameraButton.addEventListener('click', function(e){
Ti.Media.takePicture();
});
@jonalter
jonalter / app.js
Created May 31, 2011 15:42
Android detect app closed with home button
Titanium.UI.setBackgroundColor('#000');
var tabGroup = Titanium.UI.createTabGroup();
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
url:'main.js'
});
var tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png',