This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//must have TiSocial module installed for iOS: https://github.com/viezel/TiSocial.Framework | |
//share() Android -- uses intent, iOS --- uses TiSocial share dialog | |
//tweet iOS Only -- uses TiSocial tweet dialog | |
function onClickShare(){ | |
require('socialmod').share({ | |
text: 'text to share', | |
title: 'Title', | |
url: 'http://example.com' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.host; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//paging through large query result sets with Titanium and ACS | |
//http://adampaxton.com | |
function doQuery(n){ | |
Cloud.Objects.query({ | |
classname: 'cars', | |
per_page: 100, | |
page: n || 1 | |
}, function (e) { | |
if (e.success) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = {}; | |
app.createContactTabGroup = function() { | |
var tg = Ti.UI.createTabGroup(); | |
var win = Ti.UI.createWindow({ | |
title : 'Contact Us', | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ti.UI.setBackgroundColor('#000'); | |
var win = Titanium.UI.createWindow({ | |
title : 'test' | |
}); | |
var arrayLength = 5 | |
var fields = new Array(arrayLength); | |
for( i = 0; i < arrayLength; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var win = Titanium.UI.createWindow({ | |
title : 'test' | |
}); | |
var view1 = Ti.UI.createView({ | |
backgroundColor:'red' | |
}); | |
var l1 = Ti.UI.createLabel({ | |
text:'View 1', | |
color:'#fff', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Creates an image view using Google's QR Code generator. | |
* @param text The text to be encoded in the QR code | |
* @param size The size of the QR code; Possible Sizes: 100x100, 150x150, 200x200, 250x250, 300x300, 350x350, 400x400, 500x500 | |
*/ | |
function createQRCodeImageView(text, size) { | |
var url = 'http://chart.apis.google.com/chart?cht=qr&chs=' + size + '&chl=' + encodeURI(text) + '&chld=H|0'; | |
var width = size.split('x')[0], height = size.split('x')[1]; | |
if (Ti.Android) { | |
width += 'dp'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// implement like this: | |
var window = Ti.UI.createWindow({ | |
backgroundColor:'#fff' | |
}); | |
// draw the gridlines first so your other elements stack on top of them | |
// without requiring you to set the z-index property of each | |
var grid = require('gridlines'); | |
grid.drawgrid(10,window); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var os = require('os').os; | |
//branch logic based on platform - saves you an if statement | |
os(function() { | |
alert('do this on android'); | |
}, function() { | |
alert('do this on iOS'); | |
}); | |
var platformSpecificValue = os('android string','ios string'); |