This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.xml: | |
<Window id="win1"> | |
<Include src="myMarkup"/> | |
</Window> | |
// myMarkup.xml: | |
<View id="mySnippet"> | |
<Label /> | |
<Button id="loginButton" /> | |
</View> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Prototype version: | |
// Ti.include('prototype.js'); | |
// Module version: | |
// Ti.include('module.js'); | |
// Factory version: | |
Ti.include('factory.js'); | |
var win = Ti.UI.createWindow({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"title" : "A blog post", | |
"author" : "Kristina", | |
"content" : "...", | |
"tags" : ["MongoDB", "Map/Reduce", "Recipe"] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Dashboard controller | |
*/ | |
// Private | |
var api = require('parentcontroller'); | |
api.load = function() { | |
Ti.API.info('Child load method fired'); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' } |