Created
July 3, 2011 05:25
-
-
Save aaronksaunders/1061974 to your computer and use it in GitHub Desktop.
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 window = Titanium.UI.createWindow({ | |
}); | |
var popOver_button = Titanium.UI.createButton({ | |
title: "PopOver Button", | |
width:150, | |
height:35 | |
}) | |
window.add(popOver_button); | |
popOver_button.addEventListener('click', function() { | |
var popover = Ti.UI.iPad.createPopover({ | |
width:400, | |
height:300, | |
arrowDirection:Ti.UI.iPad.POPOVER_ARROW_DIRECTION_ANY, | |
navBarHidden:true, | |
}); | |
// add navigationGroup to popOver | |
var navigationGroup = createPopOverNavigationGroup( popover ); | |
popover.add(navigationGroup); | |
popover.show({ | |
view:popOver_button, | |
animated:true | |
}); | |
}); | |
window.open(); | |
/** | |
* create the popover window when the user clicks the button | |
*/ | |
function createPopOverNavigationGroup(popover) { | |
// add close button to close the popover | |
var close_button = Ti.UI.createButton({ | |
title:'Close' | |
}); | |
close_button.addEventListener('click', function() { | |
popover.hide({ | |
animated:true | |
}); | |
}); | |
var win1 = Titanium.UI.createWindow({ | |
title: "NavGroup In Popover", | |
backgroundColor:'#fff', | |
barColor:'black' | |
}); | |
win1.rightNavButton = close_button; | |
// create a table with some rows to click, a pretty common use of navGroup | |
var tableView = Titanium.UI.createTableView({ | |
width:'100%', | |
height:'100%', | |
rowHeight: 'auto', | |
barColor:'black', | |
data:[{ | |
title:"Row1" | |
},{ | |
title:"Row2" | |
}] | |
}); | |
win1.add(tableView); | |
// create the navigationGroup | |
var navGroup = Ti.UI.iPhone.createNavigationGroup({ | |
window : win1 | |
}); | |
// event listener for the clicks | |
tableView.addEventListener('click', function(e) { | |
// create window when row is clicked and show title of row | |
var detailWindow = Ti.UI.createWindow({ | |
barColor:'black', | |
title : "Detail Window", | |
backButtonTitle:"Back", | |
}); | |
// label to show the title | |
var label = Titanium.UI.createLabel({ | |
text: "Clicked " + e.row.title, | |
width:'100%', | |
color:'white', | |
height:35, | |
textAlign:'center' | |
}) | |
detailWindow.add(label); | |
// open the window using the navGroup | |
navGroup.open(detailWindow); | |
}); | |
return navGroup; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment