Skip to content

Instantly share code, notes, and snippets.

View dawsontoth's full-sized avatar

Dawson Toth dawsontoth

View GitHub Profile
@dawsontoth
dawsontoth / app.js
Created April 6, 2011 22:42
long touch
var holdTime = 1000, holdStartCoords = { x: 0, y: 0 }, holdStartRow, timeout = false, didLongTouch = false;
$(table)
.click(function(evt) {
if (didLongTouch) {
didLongTouch = false;
return;
}
clearTimeout(timeout);
if (evt.row == null) {
return;
@dawsontoth
dawsontoth / LinksInExternalWebViews.js
Created March 21, 2011 16:51
The following snippet takes over links in a webview of a remote URL, causing them to do nothing but Ti.App.fireEvent('linkClicked', { href: 'http://example.com' }). This lets you load in web pages, and control what should happen when a link is clicked (li
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
var web = Ti.UI.createWebView({
url: 'http://www.appcelerator.com/'
});
var linkJS = 'document.titaniumLinkQueue = [];'
+ '(function(){'
+ 'var links = document.getElementsByTagName("a");'
+ 'for(var i = 0, l = links.length; i < l; i++) {'
@dawsontoth
dawsontoth / app.js
Created March 14, 2011 18:23
Sample tab group with an omnipresent bar at the top
/**
* Create a "container" window. This will house all of our high level UI elements
*/
var container = Ti.UI.createWindow({
backgroundColor: 'yellow'
});
/**
* Add some stuff to the top of the container. This will be visible everywhere in the app
*/
@dawsontoth
dawsontoth / postingToGitHub.html
Created March 14, 2011 17:59
How to post Gists to GitHub
<html>
<head>
<style type="text/css">
body {
font: 14px Verdana, Geneva, sans-serif;
height: 500px;
width: 700px;
margin: 10px 20px;
}
@dawsontoth
dawsontoth / app.js
Created March 11, 2011 01:40
Tab within a Tab
var tabGroupOuter = Ti.UI.createTabGroup();
tabGroupOuter.addTab(Ti.UI.createTab({
title: 'app.js',
window: Ti.UI.createWindow({
title: 'app.js',
url: 'middle.js',
backgroundColor: 'red'
})
}));
tabGroupOuter.open();
@dawsontoth
dawsontoth / notificationsInAndroid.js
Created March 4, 2011 22:33
Notifications in Android using Titanium Appcelerator Mobile
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
win.add(Ti.UI.createLabel({ text: 'Look for the notification! It should be there now.' }));
win.open();
Titanium.Android.NotificationManager.notify(
0, // <-- this is an ID that we can use to clear the notification later
Ti.Android.createNotification({
contentTitle: 'Cheese, Gromit!',
contentText: 'Swiss',
tickerText: 'Our app made a notification!',
@dawsontoth
dawsontoth / t.sh
Created March 4, 2011 19:37
Bash script to quickly simulate / emulate / deploy Appcelerator Titanium Mobile apps
##
# This script helps you run Titanium Mobile apps from the command line.
#
# You will want to customize the variables on lines 25-37, per your own environment.
# Most important is to customize "appRootDirectory".
#
# It can be used a couple of different ways:
# 1) To start the Android emulator:
# ./t a
# 2) To start a simulator, emulator, or deploy to device, use the following:
@dawsontoth
dawsontoth / contextMenusInTiDesktop.html
Created March 4, 2011 17:28
Context menus in Titanium Desktop, a quick sample.
<html>
<body>
<style type="text/css">
body {
-webkit-user-select: auto !important;
}
</style>
Here is some text.
<br />
<textarea rows="10" cols="70">
@dawsontoth
dawsontoth / app.js
Created March 4, 2011 00:44
Customize the look of the tab bar in iOS Appcelerator Titanium
Ti.include('overrideTabs.js');
/*
This is a typical new project -- a tab group with three tabs.
*/
var tabGroup = Ti.UI.createTabGroup();
/*
Tab 1.
@dawsontoth
dawsontoth / LinksInWebViews.js
Created March 3, 2011 16:54
The following snippet takes over links in webviews, causing them to do nothing but Ti.App.fireEvent('linkClicked', { href: 'http://example.com' }). This lets you load in web pages, and control what should happen when a link is clicked.
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
var html = '<html><body>'
+ '<a href="http://pedro.com">Pedro</a> '
+ '<a href="http://is.com">is</a> '
+ '<a href="http://a.com">a</a> '
+ '<a href="http://balla.com">balla!</a>.'
+ '</body></html>';
var web = Ti.UI.createWebView({