Skip to content

Instantly share code, notes, and snippets.

View bob-sims's full-sized avatar

Bob Sims bob-sims

View GitHub Profile
@dawsontoth
dawsontoth / app.js
Created May 10, 2011 14:05
Loading images in @appcelerator #Titanium
/* The images for this example can be downloaded from http://j.mp/loadingimagesforti */
var win = Ti.UI.createWindow({ backgroundColor: '#f00'});
var loading = Ti.UI.createImageView({
images: [
'images/loading/00.png', 'images/loading/01.png', 'images/loading/02.png',
'images/loading/03.png', 'images/loading/04.png', 'images/loading/05.png',
'images/loading/06.png', 'images/loading/08.png', 'images/loading/09.png',
'images/loading/10.png', 'images/loading/11.png'
],
width: 33, height: 33
var container = Ti.UI.createView({
layout:'vertical',
top:5, left:5, right:5
});
var bar = Ti.UI.createView({
top:5,
left:0,
width:'75%',
height:40,
@atsusy
atsusy / gist:998503
Created May 30, 2011 05:50
Titanium Mobile sample code(podcast player)
/*
* ユーザーインタフェース
*/
var window = Titanium.UI.createWindow({});
var feedsTable = Titanium.UI.createTableView({});
var playingPanel = Titanium.UI.createView({
bottom:-65,
@donayama
donayama / app.js
Created June 5, 2011 13:09
FlickrShow
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
Titanium.UI.iPhone.statusBarStyle = Titanium.UI.iPhone.StatusBar.OPAQUE_BLACK;
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
//
// create base UI tab and root window
//
@dawsontoth
dawsontoth / app.js
Created June 6, 2011 20:40
Rate my app in Appcelerator Titanium Mobile
/**
* The following snippet will ask the user to rate your app the second time they launch it.
* It lets the user rate it now, "Remind Me Later" or never rate the app.
*/
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
win.addEventListener('open', checkReminderToRate);
win.add(Ti.UI.createLabel({ text: 'This is a simple app that will remind you to rate it.' }));
win.open();
function checkReminderToRate() {
@zeuxisoo
zeuxisoo / app.js
Created June 9, 2011 04:15
Titanium mobile parse html
Ti.include('lib/htmlparser.js');
Ti.include('lib/soupselect.js');
var select = soupselect.select;
var body = '<html><head><title>Test</title></head>'
+ '<body>'
+ '<img src="http://l.yimg.com/mq/i/home/HKGallery.gif" />'
+ '<div id="block">'
+ ' <div class="row">Row 1</div>'
@pec1985
pec1985 / app.js
Created June 13, 2011 17:43
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');
@powmedia
powmedia / gist:1081802
Created July 14, 2011 01:58
Backbone.sync for Titanium
//Customise Backbone.sync to work with Titanium rather than jQuery
Backbone.sync = (function() {
var methodMap = {
'create': 'POST',
'read' : 'GET',
'update': 'PUT',
'delete': 'DELETE'
};
var xhr = Ti.Network.createHTTPClient({ timeout: 5000 });
var os = require('os').os;
//branch logic based on platform - saves you an if statement
os(function() {
alert('do this on android');
}, function() {
alert('do this on iOS');
});
var platformSpecificValue = os('android string','ios string');
@pec1985
pec1985 / app.js
Created August 1, 2011 20:41
XHR function with callback
HTTPRequest({
ur:'http://example.com/somefile.json',
type:'GET',
success: function(a){
var json = JSON.parse(a);
// do something else
},
error: function(response, message){
// handle error
}