Skip to content

Instantly share code, notes, and snippets.

@anfaguerrero
Forked from aaronksaunders/app.js
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anfaguerrero/bf47b315178d9d2f2deb to your computer and use it in GitHub Desktop.
Save anfaguerrero/bf47b315178d9d2f2deb to your computer and use it in GitHub Desktop.
//
// Aaron K. Saunders
//
// http://www.clearlyinnovative.com
// http://blog.clearlyinnovative.com
// @aaronksaunders
//
//
(function() {
var group, tab1, tab2, win1, win2;
group = Ti.UI.createTabGroup();
var windowFactory = function(options) {
this.tab = options.tab;
this.win = Ti.UI.createWindow({
title : options.title || 'Window 1'
});
this.win.addEventListener('swipe', function(e) {
Ti.API.info('swipe fired x ' + e.x + ' y ' + e.y + ' direction ' + e.direction);
if(e.direction === 'left') {
var newWindow = windowFactory({
"title" : new Date(),
"tab" : e.source.tab
}).win
e.source.tab.open(newWindow)
} else if(e.direction === 'right') {
e.source.close();
}
});
return this;
}
win1 = Ti.UI.createWindow({
title : 'Window 1'
});
win1.addEventListener('click', function(e) {
group.activeTab.open(windowFactory({
"title" : new Date(),
"tab" : group.activeTab
}).win);
});
win2 = Ti.UI.createWindow({
title : 'Window 2'
});
tab1 = Ti.UI.createTab({
window : win1,
title : 'Tab 1'
});
tab2 = Ti.UI.createTab({
window : win2,
title : 'Tab 2'
});
group.addTab(tab1);
group.addTab(tab2);
group.open();
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment