Skip to content

Instantly share code, notes, and snippets.

View aaronksaunders's full-sized avatar

Aaron K Saunders aaronksaunders

View GitHub Profile
//
Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
Titanium.Geolocation.distanceFilter = .25;
Ti.Geolocation.purpose = "Callbacks Are Your Friend";
// PUBLIC FUNCTION
/**
* @param {Object} _callback call on completion of location query
*/
exports.currentLocation = function(_callback) {
// private vars
var mainWindow, callback_label_coords;
var styles = require('styles');
var maps = require('lib/maps');
/**
* @param {Object} args properties for the window
*/
exports.AppWindow = function(args) {
var instance, event_label, callback_label;
@aaronksaunders
aaronksaunders / twitter_image.js
Created October 8, 2011 19:37
Source code to upload an image using twitters new photo api
var sendTwitterImage = function(postParams, pSuccessCallback, pErrorCallback) {
var finalUrl = '';
// authorize user if not authorized, and call this in the callback
if(!authorized && ( typeof (auth) == 'undefined' || auth === true)) {
authorize(function(retval) {
if(!retval) {
// execute the callback function
if( typeof (callback) == 'function') {
callback(false);
@aaronksaunders
aaronksaunders / spinning.js
Created October 8, 2011 19:51
spinning circle in Appcelerator
//
//
var win1 = Titanium.UI.createWindow({
title : 'Tab 1',
backgroundColor : '#fff',
layout : "vertical"
});
//
var view5 = Titanium.UI.createView({
@aaronksaunders
aaronksaunders / app.js
Created October 13, 2011 00:30
nativehttpqueue module for appcelerator titanium
var nativehttpqueue = require('com.clearlyinnovative.nativeHttpQueue');
/**
additional paramater(s) supported per request
Paramaters
----------
"username" : "<username>"
"password" : "<password>"
"domain" : "<domain>" domain for NTLM
@aaronksaunders
aaronksaunders / app.js
Created October 15, 2011 06:58
Text field validator only alpha
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
win1.open();
var alphaonly = Titanium.UI.createTextField({
color:'#336699',
height:35,
width:300,
@aaronksaunders
aaronksaunders / app.js
Created October 16, 2011 07:04
Handling click event in button/view on a row
var win = Ti.UI.createWindow({});
var tableView = Ti.UI.createTableView({});
for(var i = 0; i < 5; i++) {
var checkBox = Ti.UI.createView({
width : 20,
height : 20,
done : false,
item_type : "CHECKBOX", // us this to know we clicked a checkbox
@aaronksaunders
aaronksaunders / app_2.js
Created October 16, 2011 07:54
More Fun with TableView Rows
var win = Ti.UI.createWindow({});
var tableView = Ti.UI.createTableView({});
for(var i = 0; i < 5; i++) {
var checkBox = Ti.UI.createView({
width : 20,
height : 20,
done : false,
item_type : "CHECKBOX", // us this to know we clicked a checkbox
@aaronksaunders
aaronksaunders / helper.js
Created October 16, 2011 07:58
Simple function to find child objects
/**
* helper to find an element, can be used when there are
* multiple elements in a row and you need to find one
*
* @param _o {Object} parent object to find elements in
* @param _i {String} id of the element you are looking for
*/
function findElement(_o, _i) {
for(var x in _o.children) {
if(_o.children[x].id === _i) {
@aaronksaunders
aaronksaunders / helper2.js
Created October 16, 2011 08:15
Function to scan through table rows to determine which ones are selected
/**
* simple method to get the list of items selected
*/
function checkedRowsAre() {
// get the rows; there is a default section in all tables so that
// is why we need to get the rows this way
var selected = [];
var rows = tableView.data[0].rows;
// iterate through the rows to find out which ones are selected,