Skip to content

Instantly share code, notes, and snippets.

View brentonhouse's full-sized avatar
🚀
Busy being awesome!

Brenton House brentonhouse

🚀
Busy being awesome!
View GitHub Profile
var Win = Ti.UI.createWindow({
title: "My Message",
});
var ScrollView = Ti.UI.createScrollView({
height: Ti.UI.FILL,
width: Ti.UI.FILL,
contentHeight: "100%",
contentWidth: "100%",
});
/**
* Caching functions class
* @class Cache
*/
var Moment = require("alloy/moment");
var directory;
exports.valid = function (_url) {
var fileName = _url.replace(/[^\w\d]/g, "");
/**
* Structure of an alloy controller
**/
function Controller() {
var $ = this;
}
module.exports = Controller;
/**
@jasonkneen
jasonkneen / sample.js
Last active August 29, 2015 14:01
DynamicLabel tag in Alloy - allows you to update a "value" and it applies it to a template. Place ui.js in your app/lib folder
$.recordCount.value = 99
@rblalock
rblalock / controller.js
Last active August 29, 2015 14:04
Idea for an uber-simplistic view / data binding in Alloy
var TiBind = require("ti.bind");
var data = [
{ someTitle: "Hello World" }
];
TiBind($, data);
@pec1985
pec1985 / TableViewIndex.js
Last active September 25, 2015 11:08
Get the right column of letters on a table view
/* Ever wondered how to get the nice column of letters in the right side
* of the table view?
*
* Here is an example:
* 1. We take a list of names from a json file
* 2. We need to sort them by either first name or last name
* 3. We need to create a row header once in a while, when the first letter changes
* 4. We need to create a table index
*
*/
@adampax
adampax / titanium-array-form-next-key.js
Created October 20, 2011 17:59
Simple Titanium form saved in an array with return key eventlistener moving to the next field
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++) {
@pec1985
pec1985 / app.js
Created February 13, 2012 20:13
Lock Screen for iOS apps - Titanium
function PassCode(_params){
_params = _params || {};
// @PARAMS:{
// boxSize: (Number) size of the passcode character boxes
// backgroundColor: (String) background color of the mainview
// backgroundImage: (String) background image of the mainview
// panicColor: (String) background color of the view when panic() is called - when wrong password
// titleText: (String) the text of the title view, above the pass code boxes by default,
// mainView: (Object) params for the main view that hold the passcode boxes
@donayama
donayama / PlatformRequire.js
Created March 26, 2012 22:22
TiShadow iOS Simulator Patch (from line:29)
var log = require("/api/Log");
var os = Ti.Platform.osname;
// The TiShadow build of the Titanium SDK does not cache CommonJS modules loaded
// from the applicationDataDirectory. This is so that if an update to the app is
// deployed, i.e. a file in the applicationDataDirectory is modified, the changes
// while be loaded. That said loading a CommonJS module every time that it is loaded
// make the deployed bundle run slowly. So we will manage the caching of those
// modules here in the code.
@kriskowal
kriskowal / cancelable-xhr.js
Created July 31, 2012 00:56
Demonstration of Mark Miller’s idea for cancelable promises: return the deferred.
var cancelableRequest = function (url) {
var xhr = new XMLHttpRequest();
var deferred = Q.defer();
function onload() {
if (xhr.status === 200 || xhr.status === 0 && xhr.responseText) {
deferred.resolve(xhr.responseText);
} else {
onerror();
}