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
Created March 16, 2015 19:15
Using DOM calls from Appcelerator MobileWeb
function doClick(e) {
if(OS_MOBILEWEB){
var btn=document.createElement("BUTTON");
btn.style.position='absolute';
var t=document.createTextNode("CLICK ME");
btn.appendChild(t);
document.body.appendChild(btn);
@alanleard
alanleard / 0_reuse_code.js
Last active August 29, 2015 14:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@alanleard
alanleard / gist:61031aa6ba2aff8e26c5
Created September 10, 2014 19:38
Underline example
var text = "Have you tried <u>hyperloop</u> yet?";
if(OS_IOS){
var iOSText = text.replace(/<u>|<\/u>/g,"");
var attr = Ti.UI.iOS.createAttributedString({
text: iOSText,
attributes: [
{
type: Ti.UI.iOS.ATTRIBUTE_UNDERLINES_STYLE,
value: Titanium.UI.iOS.ATTRIBUTE_UNDERLINE_STYLE_SINGLE,
<manifest>
<!-- Allows the API to download data from Google Map servers -->
<uses-permission android:name="android.permission.INTERNET"/>
<!-- Allows the API to cache data -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- Use GPS for device location -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- Use Wi-Fi or mobile connection for device location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<!-- Allows the API to access Google web-based services -->
@alanleard
alanleard / app.js
Created April 17, 2014 23:21
ListView Children
var win = Ti.UI.createWindow({backgroundColor: 'white'});
var search = Titanium.UI.createSearchBar({
barColor:'#000',
showCancel:true,
height:43,
top:0,
});
search.addEventListener('cancel', function(){
@alanleard
alanleard / app.js
Created April 16, 2014 01:39
ListView Parent Events
var win = Ti.UI.createWindow({backgroundColor: 'white'});
var search = Titanium.UI.createSearchBar({
barColor:'#000',
showCancel:true,
height:43,
top:0,
});
search.addEventListener('cancel', function(){
@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({
@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 / 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.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({