Skip to content

Instantly share code, notes, and snippets.

@mauropm
mauropm / jsstest.js
Created December 13, 2011 23:36
Small JSS Test with V8 + Titanium Appcelerator
//This should be pasted as app.js into a new Titanium Project,
//with MobileSDK 1.8RC1, using V8 as the JS engine.
var window = Ti.UI.createWindow({
id:"w"
});
var b=Ti.UI.createButton({
id:"b1"
});
@mauropm
mauropm / testingxmlattr.js
Created December 14, 2011 00:26
Testing XML Parsing of attributes
var str = "<test name='appcelerator'/>"
var xml = Ti.XML.parseString(str);
var node = xml.documentElement;
//Ti.API.info("Attributes: "+xml.attributes);
if (node.attributes && (node.attributes.length > 0)) {
Ti.API.info(" Value: "+node.attributes.item(0).nodeValue);
};
win = Ti.UI.createWindow();
win.open();
@mauropm
mauropm / testingversion.js
Created December 14, 2011 00:53
Testing Version Tag on iOS
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
Ti.API.info("Version: "+Ti.App.version);
//
// create base UI tab and root window
@mauropm
mauropm / exampleui.js
Created December 14, 2011 21:54
Example NS and dynamic creation of views
tt.ui.createStackView = function(_args) {
var stack = Ti.UI.createView(tt.combine($$.stretch,_args.props||{}));
stack.currentIndex = _args.currentIndex||0;
//populate stack
for (var i = 0; i < _args.views.length; i++) {
var w = _args.views[i];
if (i == stack.currentIndex) {
w.visible = true;
@mauropm
mauropm / activity.js
Created December 15, 2011 00:40
Showing ActivityIndicator inside a View
var win1 = Titanium.UI.createWindow({
title:'Test',
backgroundColor:'#000'
});
var myview = Ti.UI.createView();
var actInd = Titanium.UI.createActivityIndicator({
height:50,
width:10
@mauropm
mauropm / padding.js
Created December 15, 2011 22:11
Example Padding on labels
/* Example of padding in labels -
* Mauro Parra-Miranda mauropm@gmail.com
*/
var vLabel = Ti.UI.createView({
width: 300,
height: 35,
top: 120
});
@mauropm
mauropm / lostevents.js
Created December 15, 2011 23:52
Example Losing Events inside ScrollView
var textWindow = Ti.UI.createWindow({
backgroundColor:'white',
borderColor: 'black',
borderWidth: 1,
width: '100%',
height: '100%',
navBarHidden: true
});
var scrollView = Ti.UI.createScrollView({
layout: 'vertical',
@mauropm
mauropm / customTabsIniOS.js
Created December 16, 2011 21:13 — forked from dawsontoth/app.js
Customize the look of the tab bar in iOS Appcelerator Titanium
/**
* Override a tab group's tab bar on iOS.
*
* NOTE: Call this function on a tabGroup AFTER you have added all of your tabs to it! We'll look at the tabs that exist
* to generate the overriding tab bar view. If your tabs change, call this function again and we'll update the display.
*
* @param tabGroup The tab group to override
* @param backgroundOptions The options for the background view; use properties like backgroundColor, or backgroundImage.
* @param selectedOptions The options for a selected tab button.
* @param deselectedOptions The options for a deselected tab button.
@mauropm
mauropm / fb.js
Created December 22, 2011 01:53
FB ID
var win = Ti.UI.createWindow({});
var sv = Ti.UI.createScrollView({
contentWidth:'auto',
contentHeight:'auto',
top:0,
showVerticalScrollIndicator:true,
showHorizontalScrollIndicator:true
});
win.add(sv);
@mauropm
mauropm / app.js
Created December 22, 2011 19:08
Two Labels per Row in a Table
var win = Ti.UI.createWindow({
title:'testing labels',
});
var row=Ti.UI.createTableViewRow({
layout:'vertical',
height:'auto'
});
var firstLabel= Ti.UI.createLabel({
top:10,