Guest User

Untitled

a guest
Oct 18th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. // File: app.js
  2. Ti.include('windows.js');
  3.  
  4. var window = Ti.UI.createWindow();
  5.  
  6. var thisWinCreated = createMyWin();//Created From Windows.js
  7.  
  8. var modalWin = Ti.UI.createWindow({
  9. backgroundColor:"red",
  10. url:thisWinCreated
  11. });
  12.  
  13. //open a main window in a navGroup and add 1 button
  14. var nav = Ti.UI.iPhone.createNavigationGroup({
  15. window:modalWin
  16. });
  17.  
  18. window.add(nav);
  19.  
  20. var btn1 = Titanium.UI.createButton({
  21. title:'Test', top:100, left:20, width:200, height:30
  22. });
  23.  
  24. modalWin.setRightNavButton(btn1);
  25.  
  26. btn1.addEventListener('click', function(e){
  27. thisWinCreated.open({modal:true});
  28. });
  29.  
  30. window.open();
  31.  
  32.  
  33. //File: windows.js
  34. function createMyWin(){
  35.  
  36. Ti.API.info('My Window has been created');
  37.  
  38. var win = Ti.UI.createWindow({
  39. backgroundColor:'green',
  40. title:'My window created',
  41. });
  42. win.orientationModes = [
  43. Ti.UI.PORTRAIT,
  44. Ti.UI.UPSIDE_PORTRAIT
  45. ];
  46.  
  47. var done = Titanium.UI.createButton({
  48. systemButton:Titanium.UI.iPhone.SystemButton.DONE
  49. });
  50.  
  51. win.setRightNavButton(done);
  52.  
  53. done.addEventListener('click',function()
  54. {
  55. win.close();
  56. });
  57.  
  58. win.addEventListener('focus', function(){
  59.  
  60. setTimeout(function()
  61. {
  62. Ti.API.info('3 secs elapsed ... Closing Window');
  63. win.close();//will be closed in 3 secs ...
  64. },3000);
  65.  
  66. });
  67.  
  68. return win;
  69. };
Add Comment
Please, Sign In to add comment