WebView.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. "atomic component";
  2. var WIDTH = 1080;
  3. var HEIGHT = 600;
  4. // Create the UI view
  5. var view = new Atomic.UIView();
  6. //UI component
  7. exports.component = function(self) {
  8. function createTab(url) {
  9. var button = new Atomic.UIButton();
  10. button.text = url;
  11. button.urlEnabled = false;
  12. tabLayout.addChild(button);
  13. var webView = new WebView.UIWebView(url);
  14. contentRoot.addChild(webView);
  15. }
  16. var window = new Atomic.UIWindow();
  17. window.text = "UIWebView Example Browser";
  18. window.setSize(WIDTH, HEIGHT);
  19. var layout = new Atomic.UILayout();
  20. layout.axis = Atomic.UI_AXIS_Y;
  21. layout.layoutDistribution = Atomic.UI_LAYOUT_DISTRIBUTION_GRAVITY;
  22. layout.gravity = Atomic.UI_GRAVITY_ALL;
  23. // address bar
  24. var addressLayout = new Atomic.UILayout();
  25. addressLayout.gravity = Atomic.UI_GRAVITY_ALL;
  26. addressLayout.layoutDistribution = Atomic.UI_LAYOUT_DISTRIBUTION_GRAVITY;
  27. var backButton = new Atomic.UIButton();
  28. backButton.text = "Back";
  29. addressLayout.addChild(backButton);
  30. var fwdButton = new Atomic.UIButton();
  31. fwdButton.text = "Forward";
  32. addressLayout.addChild(fwdButton);
  33. var reloadButton = new Atomic.UIButton();
  34. reloadButton.text = "Reload";
  35. addressLayout.addChild(reloadButton);
  36. var homeButton = new Atomic.UIButton();
  37. homeButton.text = "Home";
  38. addressLayout.addChild(homeButton);
  39. var addressEdit = new Atomic.UIEditField();
  40. addressEdit.gravity = Atomic.UI_GRAVITY_ALL;
  41. addressLayout.addChild(addressEdit);
  42. layout.addChild(addressLayout);
  43. // bookmark bar
  44. var bookmarkLayout = new Atomic.UILayout();
  45. bookmarkLayout.gravity = Atomic.UI_GRAVITY_ALL;
  46. var atomicButton = new Atomic.UIButton();
  47. atomicButton.text = "Atomic Game Engine";
  48. atomicButton.skinBg = "TBButton.flat";
  49. bookmarkLayout.addChild(atomicButton);
  50. var youtubeButton = new Atomic.UIButton();
  51. youtubeButton.text = "YouTube";
  52. youtubeButton.skinBg = "TBButton.flat";
  53. bookmarkLayout.addChild(youtubeButton);
  54. layout.addChild(bookmarkLayout);
  55. var tabContainer = new Atomic.UITabContainer();
  56. tabContainer.gravity = Atomic.UI_GRAVITY_ALL;
  57. var contentRoot = tabContainer.contentRoot;
  58. var tabLayout = tabContainer.tabLayout;
  59. createTab("http://atomicgameengine.com/blog/development-digest-4/");
  60. createTab("https://store.steampowered.com/");
  61. createTab("https://github.com/AtomicGameEngine/AtomicGameEngine");
  62. // Add to main UI view and center
  63. layout.addChild(tabContainer);
  64. window.addChild(layout);
  65. view.addChild(window);
  66. window.center();
  67. tabContainer.currentPage = 0;
  68. }
  69. // The Web View
  70. //var webView = new WebView.UIWebView("https://ace.c9.io/build/kitchen-sink.html");
  71. //var webView = new WebView.UIWebView("https://store.steampowered.com");
  72. //var webView = new WebView.UIWebView("https://pixlcore.com/demos/webcamjs/demos/basic.html");
  73. //var webView = new WebView.UIWebView("https://getmosh.io/");
  74. //var webView = new WebView.UIWebView("http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_textarea");