Guest User

Untitled

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