Skip to content

Instantly share code, notes, and snippets.

@sr3d
Created March 30, 2011 20:40
Show Gist options
  • Save sr3d/895251 to your computer and use it in GitHub Desktop.
Save sr3d/895251 to your computer and use it in GitHub Desktop.
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