Guest User

Untitled

a guest
Jan 23rd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. function createWebView(options) {
  2. options = _.extend({
  3. title: 'Web',
  4. url: '',
  5. controlHidden: false,
  6. tabBarHidden: false
  7. }, options || {} );
  8.  
  9. var win = Ti.UI.createWindow({ title: options.title, barColor: App.styles.barColor, tabBarHidden: options.tabBarHidden });
  10. win.orientationModes = [ Ti.UI.PORTRAIT, Ti.UI.LANDSCAPE_LEFT, Ti.UI.LANDSCAPE_RIGHT ];
  11. var webView = Ti.UI.createWebView( {top: 0});
  12. webView.url = options.url;
  13. if(!options.controlHidden) {
  14. var nav = Ti.UI.createButtonBar({ labels:['Back', 'Reload', 'Forward'], backgroundColor: App.styles.tabbedBarColor });
  15. var flexSpace = Ti.UI.createButton({ systemButton: Ti.UI.iPhone.SystemButton.FLEXIBLE_SPACE });
  16. win.setToolbar([flexSpace,nav,flexSpace]);
  17. nav.addEventListener('click',function(e) {
  18. switch(e.index) {
  19. case 0:
  20. webView.goBack();
  21. break;
  22. case 1:
  23. webView.reload();
  24. break;
  25. case 2:
  26. webView.goForward();
  27. break;
  28. };
  29. });
  30. };
  31.  
  32. win.add(webView);
  33. win.leftNavButton = Ti.UI.createLabel({});
  34. var closeBtn = Ti.UI.createButton({ title: 'Close' });
  35. closeBtn.addEventListener('click', function(e) { win.close(); } );
  36. win.rightNavButton = closeBtn;
  37. return win;
  38. };
Add Comment
Please, Sign In to add comment