Skip to content

Instantly share code, notes, and snippets.

View QGao's full-sized avatar

Qing Gao QGao

  • Mountain View, CA
View GitHub Profile
<Alloy>
<View id="header">
<View id="titleContainer">
<Label id="title">title</Label>
<Label id="itemCount">3</Label>
<View id="caretIcon"/>
</View>
<Button id="addExpense" onClick="add"/>
</View>
</Alloy>
var _args = arguments[0] || {};
$.title.text = _args.title;
$.title.itemCount = _args.count;
function add(e){
Ti.API.info(JSON.stringify(_args));
_args.addFunction;
}
function addExpense(e){
Ti.API.info("addExpense is called");
alert("adding?");
}
var header = Alloy.createController("itemHeader", {
title:"Expenses",
count:"3",
addFunction: addExpense
});
/**
* Global singleton
*/
var APP = {
/**
* This sets up global events, persistant things
* throughout the app, etc. Only should be called
* when the app is booted.
*/
var lineItemsSection = Ti.UI.createTableViewSection({
headerView : lineItemsHeaderView
});
var rows = [];
for(var i = 0; i < itemCount; i++) {
var tableViewRow = Ti.UI.createTableViewRow({
id : "lineItemDetails",
data : data[i],
-------content of app.js--------
Ti.include('somefolder/platform.js');
Ti.include('somefolder/API.js');
Ti.include('somefolder/modules.js');
Ti.include('somefolder/UI.js');
MyApp = {
Platform:{},
API:{},
Modules:{},
@QGao
QGao / gist:2564011
Created May 1, 2012 00:37
A sample for sending email.
var win = Ti.UI.createWindow();
var label1 = Ti.UI.createLabel
({
text:'Some Documents listed',
font:{fontWeight:'bold', fontSize:14},
color: '#8c0000',
height: 'auto',
left: 10,
top:10
@QGao
QGao / gist:1650137
Created January 20, 2012 23:11
A n ice singleton patten sample from Rick
/**
* A singleton object
*
* Singleton objects are useful but use them sparingly. By using singletons
* you are creating dependencies in your software that might not be necessary.
* If you find yourself using this over and over again you probably need
* to rethink what you're doing. Remember, in general, globals are bad.
*/
var Preferences = {
fbToken: '1234',
@QGao
QGao / gist:1473515
Created December 13, 2011 19:30
toImage to png file sample
var win = Ti.UI.createWindow({
backgroundColor:'#fff'
});
var view = Ti.UI.createImageView({
height: 200,
backgroundColor:'#f00'
})
win.add(view);
@QGao
QGao / gist:1473514
Created December 13, 2011 19:30
toImage to png file sample
var win = Ti.UI.createWindow({
backgroundColor:'#fff'
});
var view = Ti.UI.createImageView({
height: 200,
backgroundColor:'#f00'
})
win.add(view);