Skip to content

Instantly share code, notes, and snippets.

@subtleGradient
subtleGradient / commonjs_app.js
Created January 4, 2010 14:36
CommonJS: Extending native prototypes from a module
require('footools').setup(Array, Boolean, Function, Number, RegExp, String);
"bar".foo(); // no Fail
//Create a container view
var container = Ti.UI.createView({
width:200,
height:200,
top:10,
left:10
});
//Create a view for our content
Titanium.UI.setBackgroundColor('#000');
// Create a window
var win = Titanium.UI.createWindow({
title:'Web Test',
backgroundColor:'#fff'
});
// and now a webView
var webview1 = Titanium.UI.createWebView({url:'somePage.html'});
@Takazudo
Takazudo / scripts.js
Created October 11, 2010 00:03
quick orientation detection
/* quick orientation detection */
document.body.onorientationchange = (function(){
document.body.className =
orientation % 180 == 0 ? 'vertical' : 'horizontal';
return arguments.callee;
})();
/* from http://mir.aculo.us/2010/10/08/quick-and-easy-orientation-detection-for-mobile-sites/ */
@jhaynie
jhaynie / app.js
Created November 29, 2010 05:31
translucent navbar
// make the contents of the window nav bar translucent like the iPhone app
var win = Titanium.UI.createWindow({barColor:"transparent",translucent:true});
@donthorp
donthorp / FilingIssues.md
Created December 22, 2010 16:45
Guidelines for Filing Lighthouse Tickets

Lighthouse Ticket Guidelines

  1. Please provide a detailed description of the problem and the expectation.

  2. Reproduction sequence including any working sample code or simplified project required to duplicate the problem.

  3. If there is a Q&A or Helpdesk item involved please put a link to the thread in the ticket. Hyperlink it please.

  4. Set the "Who's responsible?" field. See the platform sections below for the appropriate platform responsible party.

@remy
remy / audiosprite.js
Created December 23, 2010 13:54
An example of how an audio sprite can be used (includes fixes for iOS)
function Track(src, spriteLength, audioLead) {
var track = this,
audio = document.createElement('audio');
audio.src = src;
audio.autobuffer = true;
audio.load();
audio.muted = true; // makes no difference on iOS :(
/* This is the magic. Since we can't preload, and loading requires a user's
input. So we bind a touch event to the body, and fingers crossed, the
@dawsontoth
dawsontoth / InfiniteScrollingTableView.js
Created February 3, 2011 22:49
Infinite loading table view for iOS and Android.
/**
* We're going to create an infinite loading table view. Whenever you get close to the bottom, we'll load more rows.
*/
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
var isAndroid = Ti.Platform.osname === 'android';
/**
* Create our UI elements.
*/
var table = Ti.UI.createTableView({ top: 0, right: 0, bottom: 0, left: 0 });
@dawsontoth
dawsontoth / app.js
Created February 4, 2011 23:21
CSS Injection on External Websites using Appcelerator Titanium
// create our web view
var win = Ti.UI.createWindow({ backgroundColor: "#fff" });
var web = Ti.UI.createWebView({ url: "http://chicago.craigslist.org/" });
// inject our css when the web view finishes loading (because we need to inject into the head element)
web.addEventListener('load', function () {
// first, specify the CSS file that we should load
var cssFileName = 'styles.css';
// read in the contents
var cssFromFile = Ti.Filesystem.getFile(cssFileName);
@dawsontoth
dawsontoth / tweetView.js
Created February 10, 2011 04:07
Make tweets and links clickable in Titanium Mobile! Here I make a tweet look just like it does on Twitter, and interact the same too.
/**
* Define our parser class. It takes in some text, and then you can call "linkifyURLs", or one of the other methods,
* and then call "getHTML" to get the fully parsed text back as HTML!
* @param text that you want parsed
*/
function Parser(text) {
var html = text;
var urlRegex = /((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi;