Skip to content

Instantly share code, notes, and snippets.

@aaronksaunders
Created March 29, 2011 13:36
Show Gist options
  • Save aaronksaunders/892363 to your computer and use it in GitHub Desktop.
Save aaronksaunders/892363 to your computer and use it in GitHub Desktop.
SplitViewNav = {};
// WINDOWS
SplitViewNav.masterWindow = Ti.UI.createWindow({title:'Navigation',backgroundColor:'#898989'});
/* SplitViewNav.masterWindow.add(navGroup); */
SplitViewNav.detailWindow = Ti.UI.createWindow({title:'Welcome to Burnham Parts',backgroundColor:'#fff'});
// MASTER NAV GROUP
SplitViewNav.masterNav = Ti.UI.iPhone.createNavigationGroup({
window:SplitViewNav.masterWindow
});
// DETAIL NAV GROUP
SplitViewNav.detailNav = Ti.UI.iPhone.createNavigationGroup({
window:SplitViewNav.detailWindow
});
// SPLIT VIEW
SplitViewNav.splitView = Titanium.UI.iPad.createSplitWindow({
masterView:SplitViewNav.masterNav,
detailView:SplitViewNav.detailNav,
});
// DETAIL VIEW WEBVIEW
var webView = Ti.UI.createWebView({url:"index.html"});
SplitViewNav.detailWindow.add(webView);
// CATEGORY BUTTON
SplitViewNav.masterButton = Ti.UI.createButton({
title:'Category',
height:50,
width:300,
top:40
});
SplitViewNav.masterButton.addEventListener('click', function()
{
var w = Ti.UI.createWindow({url:'category-list.js',title:'Category',backgroundColor:'#898989',
layout : 'vertical',
_parent: Titanium.UI.currentWindow,
_navGroup : SplitViewNav.masterNav,
_rootWindow : SplitViewNav.masterWindow
});
SplitViewNav.masterNav.open(w,{animated:true});
});
SplitViewNav.masterWindow.add(SplitViewNav.masterButton);
var navGroup = Ti.UI.iPhone.createNavigationGroup( {
window : SplitViewNav.masterWindow
});
// MODEL BUTTON
SplitViewNav.masterButton = Ti.UI.createButton({
title:'Model',
height:50,
width:300,
top:110
});
SplitViewNav.masterButton.addEventListener('click', function()
{
var w = Ti.UI.createWindow({url:'model-list.js',title:'Model',backgroundColor:'#898989'});
var l = Ti.UI.createLabel({
title : 'category',
layout : 'vertical'
});
SplitViewNav.masterNav.open(w,{animated:true});
});
SplitViewNav.masterWindow.add(SplitViewNav.masterButton);
// SEARCH BUTTON
SplitViewNav.masterButton = Ti.UI.createButton({
title:'Search',
height:50,
width:300,
top:180
});
SplitViewNav.masterButton.addEventListener('click', function()
{
var w = Ti.UI.createWindow({url:'search.js',title:'Search',backgroundColor:'#898989'});
var l = Ti.UI.createLabel({
title : 'category',
layout : 'vertical'
});
SplitViewNav.detailNav.open(w,{animated:true});
});
SplitViewNav.masterWindow.add(SplitViewNav.masterButton);
// WARRANTY BUTTON
SplitViewNav.masterButton = Ti.UI.createButton({
title:'Manufacturers Warranty',
height:50,
width:300,
top:250
});
SplitViewNav.masterButton.addEventListener('click', function()
{
var w = Ti.UI.createWindow({url:'warranty.js',title:'Search',backgroundColor:'#898989'});
var l = Ti.UI.createLabel({
title : 'category',
layout : 'vertical'
});
SplitViewNav.detailNav.open(w,{animated:true});
});
SplitViewNav.masterWindow.add(SplitViewNav.masterButton);
// HEATING HELPER BUTTON
SplitViewNav.masterButton = Ti.UI.createButton({
title:'The Heating Helper Booklet',
height:50,
width:300,
top:320
});
SplitViewNav.masterButton.addEventListener('click', function()
{
var w = Ti.UI.createWindow({url:'heatinghelper.js',title:'Search',backgroundColor:'#898989'});
var l = Ti.UI.createLabel({
title : 'category',
layout : 'vertical'
});
SplitViewNav.detailNav.open(w,{animated:true});
});
SplitViewNav.masterWindow.add(SplitViewNav.masterButton);
// CONTACT US BUTTON
SplitViewNav.masterButton = Ti.UI.createButton({
title:'Contact Us',
height:50,
width:300,
top:390
});
SplitViewNav.masterButton.addEventListener('click', function()
{
var w = Ti.UI.createWindow({url:'contactus.js',title:'Search',backgroundColor:'#898989'});
var l = Ti.UI.createLabel({
title : 'category',
layout : 'vertical',
rootWindow : SplitViewNav.masterWindow
});
SplitViewNav.detailNav.open(w,{animated:true});
navGroup.open(detailWindow);
});
SplitViewNav.masterWindow.add(SplitViewNav.masterButton);
// ORIENTATION NAVIGATION BUTTON
SplitViewNav.open = function()
{
Ti.API.info('in open for split view nav')
SplitViewNav.splitView.open();
};
SplitViewNav.splitView.addEventListener('visible', function(e) {
Ti.API.log('View: '+e.view);
if (e.view == 'detail') {
e.button.title = "Navigation";
SplitViewNav.detailWindow.leftNavButton = e.button;
Ti.API.log('Set button');
}
else if (e.view == 'master') {
SplitViewNav.detailWindow.leftNavButton = null;
Ti.API.log('Removed button');
}
});
SplitViewNav.splitView.open();
catWindow = Ti.UI.createWindow({title:'Category',backgroundColor:'#fff'});
var catWindow = Titanium.UI.currentWindow
// CATEGORY BUTTON
catWindow.gasBtn = Ti.UI.createButton({
title:'Gas Boilers',
height:50,
width:300,
top:40
});
catWindow.gasBtn.addEventListener('click', function()
{
var w = Ti.UI.createWindow({title:'Category',backgroundColor:'#898989',
title : 'category - gas-boilers',
layout : 'vertical',
//url: 'gas-boilers.js',
_parent: Titanium.UI.currentWindow,
_navGroup : catWindow._navGroup,
rootWindow : catWindow
});
catWindow._navGroup.open(w,{animated:true});
});
catWindow.add(catWindow.gasBtn);
var navGroup = Ti.UI.iPhone.createNavigationGroup( {
window : catWindow
});
@ollym
Copy link

ollym commented May 16, 2011

This crashes when viewing in the simulator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment