Skip to content

Instantly share code, notes, and snippets.

View alanleard's full-sized avatar

Alan Leard alanleard

View GitHub Profile
@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
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 / gist:4964354
Created February 15, 2013 23:11
Test AppCSolution Gist
Testing
@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 / 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 / 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 7, 2013 20:41
Dynamic height
var win = Ti.UI.createWindow();
var leftTileView = Ti.UI.createView({
backgroundColor:"red",
height:(Math.random()*200),
width:"59%",
left:0
});
var tileContainer = Ti.UI.createView({
@alanleard
alanleard / app.js
Created March 7, 2013 23:00
Sizing sample
var container = Ti.UI.createView({
height : Ti.UI.SIZE
});
var dashboardTileHolder = Ti.UI.createView({
top : 0,
layout : "vertical",
height : Ti.UI.SIZE
});
@alanleard
alanleard / app
Last active December 24, 2015 01:09
Android tableView pull to refresh and no results alert
var win = Ti.UI.currentWindow;
var alertDialog = Titanium.UI.createAlertDialog({
title: 'System Message',
buttonNames: ['OK']
});
var data = [
{title:"Refresh",color:'#000',height:50},
{title:"Row 1",color:'#000',height:50},
@alanleard
alanleard / gist:7778819
Created December 3, 2013 22:33
Font Size Manipulation
var args = arguments[0] || {};
var changeFontSize = null;
$.sectionTitle.text = args.title;
function setTitles(callback){
if(args.criteria) {
var cLength = args.criteria.length;
for(var i=0; i<cLength; i++){
var title = Ti.UI.createLabel({