Skip to content

Instantly share code, notes, and snippets.

View alanleard's full-sized avatar

Alan Leard alanleard

View GitHub Profile
@alanleard
alanleard / index.js
Last active December 14, 2015 13:58
Alloy table open tabs example
$.index.open();
function tableClick(e){
$.index.setActiveTab(e.rowData.tab);
}
@alanleard
alanleard / app.js
Created March 1, 2013 16:28
Custom slider
var win = Ti.UI.createWindow();
var slider = Ti.UI.createView({
height:28,
width:358,
backgroundImage:'slider.png',
top:0
});
var button = Ti.UI.createView({
@alanleard
alanleard / app.js
Last active December 14, 2015 01:59
Geolocation returning County
Ti.Geolocation.purpose = "Locate your current county";
Ti.Geolocation.getCurrentPosition(function(e){
if(Ti.Geolocation.locationServicesAuthorization != 2){
var lat = e.coords.latitude;
var lng = e.coords.longitude;
getCounty({county:"County", url:"http://labs.silverbiology.com/countylookup/lookup.php?cmd=findCounty&DecimalLatitude="+lat+"&DecimalLongitude="+lng});
@alanleard
alanleard / gist:4964354
Created February 15, 2013 23:11
Test AppCSolution Gist
Testing
@alanleard
alanleard / app.js
Created February 12, 2013 01:44
MapView custom annotation view.
var win = Ti.UI.createWindow();
win.open();
var latitude = 37;
var longitude = -122;
var pinImage = 'map-pin.png';
var selectedPinImage = 'map-pin-selected.png';
var selectedPin = null;
var contentView = Ti.UI.createView({
@alanleard
alanleard / app.js
Last active December 12, 2015 10:28
Convert Map Latitude and Longitude Points to x & y values for a given view
/*This is a simple module that requires a map, an annotation and a parent view and will return the X & Y coordinates o fthe parent view of the provided annotation based on its latitude and longitude.
*
* PARAMS:
* -annotation {Ti.Map.Annotaion object}: The annotation you want to return the coordinates for
* -map {Ti.Map.View object}: The map with that contains the annotation
* -view {Ti.UI.View object}: The view in which you want the x/y coordinates
* -callback{function}: Use a callback or just return the point value if callback is null
*
* Full example here: https://gist.github.com/alanleard/4759405
*/
@alanleard
alanleard / app.js
Last active December 12, 2015 08:08
Map annotation selected image
var win = Ti.UI.createWindow();
var pinImage = 'map-pin.png';
var selectedPinImage = 'map-pin-selected.png';
var pin1 = Titanium.Map.createAnnotation({
latitude:37.390749,
longitude:-122.081651,
title:"Appcelerator Headquarters",
subtitle:'Mountain View, CA',
@alanleard
alanleard / app.js
Created February 4, 2013 22:54
Very simple drag and drop example
var win = Ti.UI.createWindow({
backgroundColor: '#333'
});
var box = Ti.UI.createView({
backgroundColor:'blue',
center:{x:50,y:50},
height:40,
width:40
});
@alanleard
alanleard / app.js
Last active July 19, 2016 13:21
Understanding how backgroundLeftCap and backgroundTopCap work in Titanium
//This is a demo to show how backgroundLeftCap and backgroundTopCap work on the Tianium platform by Appcelerator
//Paste this code in app.js (tested on iOS)
//Screenshot: http://screencast.com/t/txWQD3l2UBN
///////////////////////////////////////////////////////////////////////////////
//Just modify these variables to see how backgroundLeftCap and topCap will work
var topCap = 20;
var leftCap = 35;
var originalImageSize = {height:100, width:100}
@alanleard
alanleard / index.php
Created January 30, 2013 18:56
Mobile App PHP redirect
<?php
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
if(stripos($ua,'android') !== false) { // && stripos($ua,'mobile') !== false) {
header('Location: https://MyAndroidAppURL');
exit();
} else if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod') || strstr($_SERVER['HTTP_USER_AGENT'],'iPad'))
{
header('Location: http://MyiTunesAppURL');
exit();
} else {