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 sometimes determines platformWidth before, rather than after a | |
// reorientation. This works around that from @FokkeZB | |
if (OS_ANDROID) { | |
Alloy.Globals.platformWidth = Alloy.Globals.platformWidth / Alloy.Globals.density; | |
Alloy.Globals.platformHeight = Alloy.Globals.platformHeight / Alloy.Globals.density; | |
if (Ti.Gesture.landscape) { | |
console.info('switching!'); |
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
Alloy.Globals.winTop = (OS_IOS && parseInt(Ti.Platform.version, 10) >= 7) ? 20 : 0; | |
Ti.UI.backgroundColor = "#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
function parseColor(color) { | |
// from http://www.bitstorm.org/jquery/color-animation/jquery.animate-colors.js | |
var match, triplet; | |
// Match #aabbcc | |
if (match = /#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/.exec(color)) { | |
triplet = [parseInt(match[1], 16), parseInt(match[2], 16), parseInt(match[3], 16), 1]; | |
// Match #abc | |
} else if (match = /#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/.exec(color)) { |
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
// define your leftView and rightView content views here... | |
var Win = require('ui/components/splitwindow'), | |
win = new Win({ | |
splitWidth: 300, | |
masterTitle: 'Master', | |
detailTitle: 'Details', | |
navBarHidden: true, | |
backgroundColor: 'transparent', | |
}, leftView, rightView); | |
win.open(); |
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 urlParser(url) { | |
url = url.replace(/[Uu]rlschemes:\/\/\?/,""); | |
return url.split('&'); | |
} | |
// check for arguments passed to this app | |
if(OS_IOS) { | |
function grabArguments() { | |
var args = Ti.App.getArguments(); | |
if(args.url) { |
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 doClick(e) { | |
if(OS_IOS) { | |
if(Ti.Platform.canOpenURL('Urlschemes://')) { | |
Ti.Platform.openURL('Urlschemes://'); | |
} else { | |
alert('You must install the Urlschemes app first'); | |
} | |
} else { | |
var didItWork = Ti.Platform.openURL('urlschemes://'); | |
if(!didItWork) { |
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
<?xml version="1.0" ?><manifest android:versionCode="1" android:versionName="1" package="com.appcelerator.holotheme" xmlns:android="http://schemas.android.com/apk/res/android"> | |
<uses-sdk android:minSdkVersion="8"/> | |
<uses-sdk android:targetSdkVersion="14"/> | |
<!-- TI_MANIFEST --> | |
<application android:debuggable="false" android:icon="@drawable/appicon" android:label="HoloTheme" android:name="HolothemeApplication" android:theme="@android:style/Theme.Holo.Light"> | |
<!-- TI_APPLICATION --> |
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
// tested on Titanium 2.1.0.v20120621224153 on iOS and Android 2.2 | |
// this sets the background color of the master UIView (when there are no windows/tab groups on it) | |
Titanium.UI.setBackgroundColor('#000'); | |
// create tab group | |
var tabGroup = Titanium.UI.createTabGroup(); | |
// |
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 : ''; | |
}, |