public
Created

remove windows

  • Download Gist
app.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
Ti.UI.setBackgroundColor('#252525');
var device = Ti.Platform.osname;
var ng = {};
 
// start data
(function() {
ng.data = {};
ng.data.device = Ti.Platform.osname;
ng.data.current_window = null;
ng.data.globalZ = 1;
ng.data.windowID = 0;
ng.data.window_stack = [];
ng.data.ipadmenu = [{
title : 'News'
}, {
title : 'Photos'
}, {
title : 'Videos'
}, {
title : 'Games'
}];
})();
// end data
 
// start functions
(function() {
ng.functions = {};
ng.functions.new_window = function(url, title, id) {
ng.data.globalZ++;
ng.data.current_window = Ti.UI.createWindow({
device : ng.data.device,
backgroundColor : '#888',
backgroundLeftCap : 1,
backgroundTopCap : 1,
top : 70,
height : 618,
left : 350,
width : 500, // 639
zIndex : ng.data.globalZ,
borderRadius : 10
});
 
// create wrapper so we can remove it AND whatever is in it.
ng.functions.wrapper = Ti.UI.createView({
top : 20,
left : 20,
bottom : 20,
right : 20
});
ng.data.current_window.add(ng.functions.wrapper);
// add new window to app
win.add(ng.data.current_window);
 
// push new window onto stack
var this_win_id = ng.data.windowID++;
ng.data.current_window.winID = this_win_id;
ng.data.window_stack.push(ng.data.current_window);
};
// make main menu on left
ng.functions.set_ipad_menu = function(device, menu) {
menu_array = [];
var len = menu.length;
for( m = 0; m < len; m++) {
var menu_item = Ti.UI.createTableViewRow({
backgroundColor : '#222',
height : 50,
width : 440,
left : 0,
top : 0,
url : menu[m].url,
id : m,
title : menu[m].title
});
 
menu_item.addEventListener('click', function(e) {
var id = e.rowData.id;
var url = e.rowData.url;
var title = e.rowData.ti;
 
// opening new top-level window so close everything and replace
for(var w in ng.data.window_stack){
if(ng.data.window_stack.length){
win.remove(ng.data.window_stack[w]);
}
}
// clean out array
ng.data.window_stack = [];
// open new window and reset vars
//ng.functions.new_window(url, title, id);
ng.data.windowID = 0;
ng.data.globalZ = 1;
});
menu_array.push(menu_item);
}
return menu_array;
};
})();
// end functions
 
// start ui
(function() {
ng.ui = {};
ng.ui.ipad = {};
// top level tabgroup for ipad
ng.ui.ipad.createRootTabgroup = function() {
var index = Ti.UI.createTabGroup();
win = Ti.UI.createWindow({
navBarHidden : true,
zIndex : 1
});
win.hideTabBar();
var tab = Titanium.UI.createTab({
window : win
});
index.addTab(tab);
// open first window onload
ng.functions.new_window('files/news/index.js', 'News', 0);
ng.ui.main_menu = Ti.UI.createTableView({
data : ng.data.ipadmenu,
backgroundColor : '#333',
left : 10,
top : 70,
width : 444,
height : 554,
borderRadius : 10,
separatorColor : 'transparent'
});
win.add(ng.ui.main_menu);
return index;
};
ng.ui.ipad.create_GENERIC_TableView = function(data, type) {
// var data = [];
tv = Ti.UI.createTableView({
backgroundColor : 'orange',
left : 0,
top : 0,
right : 0,
bottom : 0,
separatorColor : 'transparent'
});
for(var i = 0; i < data.length; i++) {
var row = Ti.UI.createTableViewRow({
backgroundColor : 'transparent',
selectedBackgroundColor : 'transparent',
top : 0,
left : 0,
right : 0,
height : 60,
title: data[i].title
});
data[i] = row;
}// end function
tv.setData(data);
return tv;
};
})();
// end ui
 
// app.js
win = ng.ui.ipad.createRootTabgroup();
win.open();

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.