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
// I am pretty sure there is a sexier approach, but this works nicely | |
var isPhone5 = Ti.Platform.displayCaps.platformHeight == 568; | |
parse568hImages = function(imagePath) { | |
if (isPhone5){ | |
// Do this because the filename could contain dots | |
imagePath = imagePath.replace(".png","-568h@2x.png"); | |
imagePath = imagePath.replace(".jpg","-568h@2x.jpg"); | |
imagePath = imagePath.replace(".jpeg","-568h@2x.jpeg"); | |
} |
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 xhr = Titanium.Network.createHTTPClient(); | |
xhr.onload = function() | |
{ | |
var results = this.responseText; | |
Ti.API.info('Results from xhr Lookup = ' + results ); | |
var supportDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'my_support'); | |
if(!supportDir.exists()){ | |
supportDir.createDirectory(); | |
} |
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 myFunction = function() { | |
if(typeof arguments[0] == 'function') { | |
arguments[0](); // throws error: [object Object] is not a function | |
// but this works | |
var cb = arguments[0]; | |
cb(); | |
} | |
}; | |
myFunction(function() { |
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 Utils = { | |
/* modified version of https://gist.github.com/1243697 | |
* adds detection of file extension rather than hard-coding .jpg as in the original | |
*/ | |
_getExtension: function(fn) { | |
// from http://stackoverflow.com/a/680982/292947 | |
var re = /(?:\.([^.]+))?$/; | |
var tmpext = re.exec(fn)[1]; | |
return (tmpext) ? tmpext : ''; | |
}, |
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 viewWithTransparentBackground = Titanium.UI.createView({ | |
backgroundColor: 'rgba(0,0,0,0.5)' // RGB way: Black background at 0.5 alpha | |
}); | |
//OR | |
var viewWithTransparentBackground = Titanium.UI.createView({ | |
backgroundColor: "#50ff0000" // hex way: red background at 0.5 alpha | |
}); |
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 CircleLoaderView = require("CircleLoaderView"); | |
var myloader = new CircleLoaderView({ | |
width : 200, | |
centerWidth : 100, | |
backgroundColor : "#fff", | |
tintColor : "blue", | |
textColor : "red", | |
labelFontSize : 28 |
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
"#scrollView": { | |
layout:"horizontal", | |
contentWidth: Ti.UI.SIZE, //andoid important | |
height:260, | |
scrollType:"horizontal", | |
horizontalWrap: false //andoid important | |
}, | |
".view": { | |
height:260, | |
width:220, |
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
function doClickMenu(evt){ | |
alert(evt.source.title); | |
} | |
// we need to do some things to the Window once it is properly instanciated, so we add an event listener to its OPEN event | |
$.win.addEventListener('open',function(){ | |
var actionBar = $.win.activity.actionBar; // get a handle to the action bar | |
actionBar.title='My App'; // change the App Title | |
actionBar.displayHomeAsUp=true; // Show the "angle" pointing back | |
actionBar.onHomeIconItemSelected = function() { // what to do when the "home" icon is pressed |
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 PX = require('com.pixate.framework'); | |
PX.styleSheetFromFilePathWithOrigin({ | |
monitor: true, | |
origin: 0, | |
filename: '/path/to/file.css' | |
}); | |
PX.styleSheetFromFilePathWithOrigin({ | |
monitor: true, | |
origin: 0, | |
filename: '/path/to/second_file.css' |
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
#! /bin/sh | |
# Run this from the folder you want to be the parent of your docs | |
# By default, generated docs go into | |
# titanium_mobile/dist/apidoc/ti_mobile_docs/ | |
# | |
# This can be changed below | |
git clone https://github.com/appcelerator/titanium_mobile.git | |
cd titanium_mobile | |
sudo apt-get install python-setuptools python-dev |