Skip to content

Instantly share code, notes, and snippets.

View grantges's full-sized avatar

Bert Grantges grantges

  • Austin, Tx - United States
View GitHub Profile
@grantges
grantges / gist:1216716
Created September 14, 2011 14:29
HTTPClient example with Authorization
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
var win = Ti.UI.createWindow({
title: "MainWindow",
layout: "vertical"
});
var username = Ti.UI.createTextField({
left: 10,
@grantges
grantges / gist:3035526
Created July 2, 2012 20:31
Creating a tableview in appcelerator with multiple views per row
/*
* Create Your Window
*/
var win = Ti.UI.createWindow({
title: 'MainWin',
backgroundColor: '#a6a6a6'
});
/*
@grantges
grantges / SliderTabGroup.js
Created July 6, 2012 17:16
SliderTabGroup for Appcelerator Titanium
$U = {};
$U.deviceType = (Ti.Platform.osname === 'ipad') ? 'tablet' : 'phone';
var SliderTabGroupButton = function(_args) {
_args = _args || {};
var borderLeft, borderRight, label;
var API = Ti.UI.createView({
@grantges
grantges / gist:3132699
Created July 17, 2012 22:55
TextField - Max Length and Event Handling
var win = Ti.UI.createWindow({layout: 'vertical', backgroundColor:'#fff'});
var textField = Ti.UI.createTextField({
height: Ti.UI.SIZE,
width: '90%',
font: {fontSize: 20},
softKeyboardOnFocus: Ti.UI.Android.SOFT_KEYBOARD_SHOW_ON_FOCUS
});
@grantges
grantges / gist:3132706
Created July 17, 2012 22:57
TableView - Rows and Border Radius
var win = Ti.UI.createWindow({layout: 'vertical', backgroundColor:'#fff'});
var data = [];
for(var i=0; i<20; i++){
var row = Ti.UI.createTableViewRow({
height: 40,
width: Ti.UI.FILL
});
row.title = 'Item '+i;
@grantges
grantges / gist:3132716
Created July 17, 2012 22:58
TextField - Focus on Window Open Event
var win = Ti.UI.createWindow({layout: 'vertical', backgroundColor:'#fff'});
var textField = Ti.UI.createTextField({
height: Ti.UI.SIZE,
width: '90%',
font: {fontSize: 20},
softKeyboardOnFocus: Ti.UI.Android.SOFT_KEYBOARD_SHOW_ON_FOCUS
});
win.add(textField);
@grantges
grantges / utils.js
Created August 14, 2012 19:34
Utility Library for Appcelerator Titanium
//Shortcuts
var $P = Ti.App.Properties;
var $F = Ti.Filesystem;
// PLATFORM RELATED Functions
exports.osname = Ti.Platform.osname;
exports.iOS = function() { return (Ti.Platform.osname === 'ipad' || Ti.Platform.osname ==='iphone')};
exports.android = function() { return Ti.Platform.osname === 'android' }
@grantges
grantges / CloudImage.js
Created August 31, 2012 10:22
Class for handling remote Images in Titanium from the Appcelerator Cloud Service.
/**
* Dependencies
*/
var ACS = require('ti.cloud');
/**
* CloudImage Definition
*/
var CloudImage = function(_args) {
@grantges
grantges / AcsPushNotify.js
Created August 31, 2012 15:20
Registering for Push Notifications in Titanium and subscribing to an Appcelerator ACS Push Notification Channel
var Cloud = require('ti.cloud');
Cloud.debug = true;
Cloud.PushNotifications.notify({
channel: 'car-checkout',
payload: {alert:'Pending Car Checkout Request', badge:1, car_id: e.rowData.car_id}, // car_id is custom prop
to_ids: '123456,78910'
}, function (e) {
if (e.success) {
alert('Your Request has been sent');
@grantges
grantges / utils.js
Created September 6, 2012 19:42
Titanium Utilities Library
//Shortcuts
var $P = Ti.App.Properties;
var $F = Ti.Filesystem;
// PLATFORM RELATED Functions
exports.osname = Ti.Platform.osname;
exports.iOS = function() { return (Ti.Platform.osname === 'ipad' || Ti.Platform.osname ==='iphone')};
exports.android = function() { return Ti.Platform.osname === 'android' }