Skip to content

Instantly share code, notes, and snippets.

View rblalock's full-sized avatar
🚀

Rick Blalock rblalock

🚀
View GitHub Profile
// index.xml:
<Window id="win1">
<Include src="myMarkup"/>
</Window>
// myMarkup.xml:
<View id="mySnippet">
<Label />
<Button id="loginButton" />
</View>
// Require works differently as you are bringing in methods and other things attached
// to it's own controller:
// index.xml
<Window id="win1">
<Require src="myThing" id="myThing" />
</Window>
// index.js controller
$.win1
$.myThing.loginButton
@rblalock
rblalock / bugbug.js
Created March 26, 2012 21:15
Scrollview / Keyboard bug
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var tf = Ti.UI.createTextField({
hintText: 'text field',
borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
height: 35,
width: 250
//single calls over bridge
var osname = Ti.Platform.osname,
version = parseInt(Ti.Platform.version);
//simple boolean checks
var isandroid = function() {
return osname === 'android';
};
var isios = function() {
@rblalock
rblalock / app.js
Created November 2, 2011 15:15
Wrapping TiUI Objects
// Prototype version:
// Ti.include('prototype.js');
// Module version:
// Ti.include('module.js');
// Factory version:
Ti.include('factory.js');
var win = Ti.UI.createWindow({
@rblalock
rblalock / example.js
Created October 24, 2011 20:03
Sample nosql
{
"title" : "A blog post",
"author" : "Kristina",
"content" : "...",
"tags" : ["MongoDB", "Map/Reduce", "Recipe"]
}
@rblalock
rblalock / implementation.js
Created October 21, 2011 20:33
Simple inheritance with CommonJS Modules and Titanium Part 2
// Create the module
var controllerModule = require('dashboardController').boot(_params);
// Test to see if the parent controller's load method or dashboardController method fires
controllerModule.load();
// Test to see other properties
Ti.API.info(controllerModule.works);
@rblalock
rblalock / dashboardController.js
Created October 21, 2011 19:10
Simple inheritance with CommonJS Modules and Titanium
/**
* Dashboard controller
*/
// Private
var api = require('parentcontroller');
api.load = function() {
Ti.API.info('Child load method fired');
};
App.loadObject = function(type, name, params) {
if(App[type] == null) {
Ti.API.warn('Trying to load an object that does not exist in the App namespace');
return false;
} else if(App[type][name] == null) {
// If the name of the type object doesn't exist
Ti.include(type.toLowerCase() + '/' + name.toLowerCase() + '.js');
Ti.API.info(type + ' ' + name + ' Loaded');
return new App[type][name](params);
} else {
var T$ = require('ti.layout'),
http = require('ti.http'),
dashboard = T$('#dashboard'), // dashboard layout
news = T$('#news'); // news layout
dashboard.bind({
windowTitle: 'Dashboard',
itemOne : { title: 'Fish', image: 'somepic.png', uid: 'fish' },
itemTwo : { title: 'News', image: 'somepic.png', uid: 'news' },
itemThree : { title: 'Settings', image: 'somepic.png', uid: 'settings' }