Skip to content

Instantly share code, notes, and snippets.

@conspirator
Created April 19, 2010 20:17
Show Gist options
  • Save conspirator/371540 to your computer and use it in GitHub Desktop.
Save conspirator/371540 to your computer and use it in GitHub Desktop.
Titanium.UI.setBackgroundColor('#000');
var tabGroup = Titanium.UI.createTabGroup();
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 1',
window:win1
});
// My Code
Titanium.App.Properties.setString("description", null);
var row1 = Ti.UI.createTableViewRow();
var descriptionLabel = Titanium.UI.createLabel({
color:'#B3B3B3',
text:'Description (optional)',
left:10,
width:280,
height:20
});
row1.add(descriptionLabel);
row1.hasChild = true;
row1.url = 'description.js';
row1.special = 'description';
var data = [];
data[0] = Ti.UI.createTableViewSection();
data[0].add(row1);
var view = Titanium.UI.createView();
var tv = Titanium.UI.createTableView({
data:data,
moving:false,
style: Titanium.UI.iPhone.TableViewStyle.GROUPED
});
view.add(tv);
view.addEventListener('click', function(e) {
if (e.rowData.url)
{
win = Titanium.UI.createWindow({
url:e.rowData.url,
backButtonTitle:'Cancel',
title:'Description'
});
tab1.open(win,{animated:true});
}
});
Titanium.App.addEventListener("descriptionChanged", function(e) {
var text = e.text;
if (text.length > 0) {
descriptionLabel.text = text;
descriptionLabel.color = '#000';
} else {
descriptionLabel.text = 'Description (optional)';
descriptionLabel.color = '#B3B3B3';
}
});
win1.add(view);
tabGroup.addTab(tab1);
tabGroup.open();
var view = Titanium.UI.createView();
var description = Titanium.UI.createTextArea({
height:180,
width:300,
top:10,
font:{fontSize:16},
keyboardType:Titanium.UI.KEYBOARD_DEFAULT,
returnKeyType:Titanium.UI.RETURNKEY_DEFAULT,
borderWidth:1,
borderColor:'#888',
color:'#000',
borderRadius:5
});
view.add(description);
var done = Titanium.UI.createButtonBar({
labels:['Done'],
backgroundColor:'#2463DE',
style:Titanium.UI.iPhone.SystemButtonStyle.DONE
});
Titanium.UI.currentWindow.setRightNavButton(done);
done.addEventListener('click', function() {
description.blur();
Titanium.App.fireEvent("descriptionChanged", {
text: description.value
});
Titanium.App.Properties.setString("description",description.value);
Titanium.UI.currentWindow.close();
});
Titanium.UI.currentWindow.add(view);
if (Titanium.App.Properties.getString("description")) {
description.value = Titanium.App.Properties.getString("description");
}
Titanium.UI.currentWindow.addEventListener('focus', function() {
description.focus();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment