Created
March 30, 2011 20:40
-
-
Save sr3d/895251 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 cachedFiles = {}; | |
/* load a file and cache it so next time we don't have to re-evaluate again */ | |
function load(path) { | |
if(!cachedFiles[path] || DEBUG ){ | |
log('caching ' + path ); | |
cachedFiles[path] = require(path); | |
}; | |
return cachedFiles[path]; | |
}; | |
/* return an intermediate page in simulator so that | |
we can re-load the top-level pages dynamically | |
*/ | |
function rootLoad(path) { | |
if(DEBUG) { | |
return { | |
createWindow: function() { | |
var win = createWindow({title: 'Landing Page'}); | |
var tableView = Ti.UI.createTableView({hasChild: true, style: Ti.UI.iPhone.TableViewStyle.GROUPED}); | |
tableView.setData([{title: 'Open Page'}]); | |
tableView.addEventListener('click', function(e) { | |
currentTabGroup.activeTab.open( load(path).createWindow() ); | |
}); | |
win.add(tableView); | |
listenToDefaultEvents(win); | |
return win; | |
} | |
}; | |
} else { | |
return load(path); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment