Guest User

Untitled

a guest
Jun 18th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. //
  2. // When you open windows outside of tab groups, they are appear on top of either
  3. // the current window or the current tab group. These examples show you different ways
  4. // to open windows outside of tab groups.
  5. //
  6.  
  7. var win = Titanium.UI.currentWindow;
  8.  
  9. win.orientationModes = [
  10. Titanium.UI.PORTRAIT,
  11. Titanium.UI.LANDSCAPE_LEFT,
  12. Titanium.UI.LANDSCAPE_RIGHT
  13. ];
  14. win.addEventListener('focus', function()
  15. {
  16. Ti.API.info('FOCUSED EVENT RECEIVED');
  17. });
  18.  
  19. //
  20. // OPEN WINDOW OUTSIDE OF TAB GROUP
  21. //
  22. var b1 = Titanium.UI.createButton({
  23. title:'Open (Plain)',
  24. width:250,
  25. height:50,
  26. top:10
  27. });
  28.  
  29. b1.addEventListener('click', function()
  30. {
  31.  
  32. var w = Titanium.UI.createWindow({
  33. backgroundColor:'#336699'
  34. });
  35.  
  36. // create a button to close window
  37. var b = Titanium.UI.createButton({
  38. title:'Close',
  39. height:30,
  40. width:150
  41. });
  42. w.add(b);
  43. b.addEventListener('click', function()
  44. {
  45. w.close();
  46. });
  47.  
  48. w.open();
  49. });
  50.  
  51. //
  52. // OPEN (ANIMATE FROM BOTTOM RIGHT)
  53. //
  54. var b2 = Titanium.UI.createButton({
  55. title:'Open (Animated)',
  56. width:250,
  57. height:50,
  58. top:70
  59. });
  60.  
  61. b2.addEventListener('click', function()
  62. {
  63. var options = {
  64. height:0,
  65. width:0,
  66. backgroundColor:'#336699',
  67. bottom:0,
  68. right:0
  69. };
  70. if (Ti.Platform.name == 'android') {
  71. options.navBarHidden = true;
  72. }
  73. var w = Titanium.UI.createWindow(options);
  74. var a = Titanium.UI.createAnimation();
  75.  
  76. // NOTE: good example of making dynamic platform height / width values
  77. // iPad vs. iPhone vs Android etc.
  78. a.height = Titanium.Platform.displayCaps.platformHeight;
  79. a.width = Titanium.Platform.displayCaps.platformWidth;
  80. a.duration = 300;
  81.  
  82. // create a button to close window
  83. var b = Titanium.UI.createButton({
  84. title:'Close',
  85. height:30,
  86. width:150
  87. });
  88. w.add(b);
  89. b.addEventListener('click', function()
  90. {
  91. a.height = 0;
  92. a.width = 0;
  93. w.close(a);
  94. });
  95.  
  96. w.open(a);
  97. });
  98.  
  99. //
  100. // OPEN (FULLSCREEN)
  101. //
  102. var b6 = Titanium.UI.createButton({
  103. title:'Open (Fullscreen)',
  104. width:250,
  105. height:50,
  106. top:130
  107. });
  108.  
  109. b6.addEventListener('click', function()
  110. {
  111. var w = Titanium.UI.createWindow({
  112. backgroundColor:'#336699'
  113. });
  114.  
  115. // create a button to close window
  116. var b = Titanium.UI.createButton({
  117. title:'Close',
  118. height:30,
  119. width:150
  120. });
  121. w.add(b);
  122. b.addEventListener('click', function()
  123. {
  124. w.close();
  125. });
  126.  
  127. w.open({fullscreen:true});
  128. });
  129.  
  130. win.add(b1);
  131. win.add(b2);
  132. win.add(b6);
Add Comment
Please, Sign In to add comment