Skip to content

Instantly share code, notes, and snippets.

View rblalock's full-sized avatar
🚀

Rick Blalock rblalock

🚀
View GitHub Profile
@rblalock
rblalock / Declarativelayout2.js
Created August 1, 2011 18:35
Procedural example
/**
* Sample declarative layout app (Procedural example)
* @version 0.1
* @author Rick Blalock
*
* App Example:
* This app uses some concepts from possible 2.0 implementations of require() along with
* using declarative layouts.
*/
@rblalock
rblalock / test2.js
Created June 17, 2011 20:57
Simple JS test of the prototype vs. module pattern in TI.
var timetest = new Date();
// TEST ONE WITH PROTOTYPE
// function User() {}
// for(var i = 0; i < 50000; i++) {
// User.prototype[i] = {};
// }
// TEST TWO Module Pattern
var timetest = new Date();
// TEST ONE WITH PROTOTYPE
// function User() {}
//
// for(var i = 0; i < 5000000; i++) {
// User.prototype[i] = {};
// }
// TEST TWO Module Pattern
/**
* List UI controller
* @class List
*/
TFA.Controllers.List = new Class({
Extends: Controller,
setOptions: {
layout : 'List', // List layout
model : 'Tasks', // Tasks model
/***************
Interface
***************/
var sync = new DataSync({
dataLocation: 'data.json',
imageLocation: 'cachedImages',
url: 'http://somewebsite.com/articles.php',
imageProperty: 'image'
});
// Assumed global app namespace
var App = {
// Example, namespaced objects
Controllers: {},
Models: {},
Views: {}
};
App.loadObject = function(type, name, params) {
if(App[type] == null) {
@rblalock
rblalock / badpractice2.js
Created May 26, 2011 21:52
bad practice2
var someNameSpace = {};
(function() {
someNameSpace.win = Ti.UI.createWindow();
someNameSpace.title = Ti.UI.createLabel();
someNameSpace.table = Ti.UI.createTableView();
someNameSpace.reset = function() {
someNameSpace.win = null;
};
})();
@rblalock
rblalock / Memoryleak.js
Created May 25, 2011 22:29
Memory leak1
var someFunction = function() {
var table = Ti.UI.createTableView(),
label = Ti.UI.createLabel();
view = Ti.UI.createView();
Ti.App.addEventListener('bad:move', function(e) {
table.setData(e.data);
});
@rblalock
rblalock / recursiveinclude.js
Created May 25, 2011 17:53
recursiveinclude
recursiveInclude = function(folder) {
var path = TiFramework.APPDIR + '/' + folder,
file = Ti.Filesystem.getFile( Ti.Filesystem.resourcesDirectory + '/' + path ),
listing = file.getDirectoryListing();
for (var i = 0; i < listing.length; i++) {
// For things like components, nested folder
if(listing[i].indexOf('.') == -1) {
Ti.include(path + '/' + listing[i] + '/' + listing[i] + '.js');
} else if(listing[i].split('.').pop() === 'js') {
@rblalock
rblalock / MemoryRelease1.js
Created May 20, 2011 17:23
Memory Release example1
/**
* Will release child objects
*/
var mypage = function() {
var win = Ti.UI.createWindow(),
table = Ti.UI.createTableView(),
label = Ti.UI.createLabel();
win.add(table);
win.add(label);