app.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. var App = (function(lng, undefined) {
  2. sectionTrigger = function(event) {
  3. event.stopPropagation();
  4. setTimeout(function() {
  5. lng.Notification.success("Event: " + event.type, "Layout events manager", "info", 2);
  6. }, 500);
  7. };
  8. articleTrigger = function(event) {
  9. event.stopPropagation();
  10. console.error(event);
  11. };
  12. environment = function(event) {
  13. var environment = lng.Core.environment();
  14. var el = lng.dom("section > article#environment");
  15. if (environment.os) {
  16. el.find("#os > strong").html(environment.os.name);
  17. el.find("#os > small").html(environment.os.version);
  18. }
  19. el.find("#resolution > strong").html(environment.screen.height + "p x " + environment.screen.width + "p");
  20. el.find("#navigator > strong").html(environment.browser);
  21. el.find("#navigator > small").html("Mobile: " + environment.isMobile);
  22. };
  23. return {
  24. sectionTrigger: sectionTrigger,
  25. articleTrigger: articleTrigger,
  26. environment: environment
  27. };
  28. })(Lungo);
  29. App.carousel = {prev: null, next: null};
  30. Lungo.Events.init({
  31. 'load section#layoutevents' : App.sectionTrigger,
  32. 'unload section#layoutevents' : App.sectionTrigger,
  33. 'load article#environment' : App.environment,
  34. 'load article#touchevents' : function(event) {
  35. ["singleTap", "doubleTap", "hold",
  36. "swipe", "-swiping", "swipeLeft", "swipeRight", "swipeUp", "swipeDown",
  37. "rotate", "rotateLeft", "rotateRight",
  38. "pinch", "pinchIn", "pinchOut",
  39. "drag", "dragLeft", "dragRight", "dragUp", "dragDown"].forEach(function(type) {
  40. $$("article#touchevents #gestures").on(type, function(event) {
  41. $$(this).siblings('.console.output').append(' | ' + type);
  42. });
  43. });
  44. $$("[data-action=clean_console]").tap(function(event) {
  45. $$('.console.output').html("");
  46. });
  47. $$("[data-action=twitter]").tap(function(event) {
  48. window.open("https://twitter.com/intent/tweet?original_referer=http%3A%2F%2Flungo.tapquo.com%2F&text=@lungojs a framework for developers who want to design, build and share cross device apps", "_blank");
  49. });
  50. },
  51. 'load section#carousel': function(event) {
  52. App.carousel = Lungo.Element.Carousel($$('[data-control=carousel]')[0], function(index, element) {
  53. Lungo.dom("section#carousel .title span").html(index + 1);
  54. });
  55. },
  56. 'tap section#carousel > header [data-direction=left]': App.carousel.prev,
  57. 'tap section#carousel > header [data-direction=right]': App.carousel.next,
  58. 'load section#pull': function(event) {
  59. App.pull = new Lungo.Element.Pull('section#pull article', {
  60. onPull: "Pull down to refresh",
  61. onRelease: "Release to get new data",
  62. onRefresh: "Refreshing...",
  63. callback: function() {
  64. alert("Pull & Refresh completed!");
  65. App.pull.hide();
  66. }
  67. });
  68. },
  69. 'touch article#notification a[data-action=normal]': function() {
  70. Lungo.Notification.show('user', 'Title', 2);
  71. },
  72. 'touch article#notification a[data-action=loading]': function() {
  73. Lungo.Notification.show();
  74. setTimeout(Lungo.Notification.hide, 3000);
  75. },
  76. 'touch article#notification a[data-action=success]': function() {
  77. Lungo.Notification.success('Title', 'Description', 'ok', 2);
  78. },
  79. 'touch article#notification a[data-action=error]': function() {
  80. Lungo.Notification.error('Title', 'Description', 'remove', 2);
  81. },
  82. 'touch article#notification a[data-action=confirm]': function() {
  83. Lungo.Notification.confirm({
  84. icon: 'user',
  85. title: 'Lorem ipsum dolor sit amet, consectetur adipisicing.',
  86. description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nemo amet nulla dolorum hic eum debitis dolorem expedita? Commodi molestiae tempora totam explicabo sed deserunt cum iusto eos perspiciatis ea in.',
  87. accept: {
  88. icon: 'checkmark',
  89. label: 'Accept',
  90. callback: function(){ alert("Yes!"); }
  91. },
  92. cancel: {
  93. icon: 'close',
  94. label: 'Cancel',
  95. callback: function(){ alert("No!"); }
  96. }
  97. });
  98. },
  99. 'touch article#notification a[data-action=html]': function() {
  100. Lungo.Notification.html('<h1>Hello World</h1>', "Close");
  101. },
  102. 'touch article#notification a[data-action=chaining]': function() {
  103. Lungo.Notification.show('user', 'user', 2, function() {
  104. Lungo.Notification.error('Title 2', 'Description 2', 'remove', 2, function() {
  105. Lungo.Notification.show('cog', 'cog', 2, function() {
  106. Lungo.Notification.html('<h1>Hello World</h1>', "Close");
  107. });
  108. });
  109. });
  110. }
  111. });
  112. Lungo.ready(function() {
  113. // Lungo.Aside.show();
  114. // Lungo.Router.section("notification");
  115. // Lungo.Notification.show();
  116. // Lungo.Notification.show("home", "Please wait...");
  117. // Lungo.Notification.show("magic");
  118. // Lungo.Notification.show("Please wait", "user", 2, function(){ alert(1); });
  119. // Lungo.Notification.error('Lorem ipsum dolor sit amet', " Lorem ipsum dolor sit amet, consectetur adipisicing elit. Reiciendis veritatis similique sed qui doloribus inventore doloremque temporibus ab totam...", 'remove');
  120. // Lungo.Notification.success('Lorem ipsum dolor sit amet', " Lorem ipsum dolor sit amet, consectetur adipisicing elit. Reiciendis veritatis similique sed qui doloribus inventore doloremque temporibus ab totam...", 'ok');
  121. // Lungo.Notification.confirm({
  122. // icon: 'user',
  123. // title: 'Lorem ipsum dolor sit amet, consectetur adipisicing.',
  124. // description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nemo amet nulla dolorum hic eum debitis dolorem expedita? Commodi molestiae tempora totam explicabo sed deserunt cum iusto eos perspiciatis ea in.',
  125. // accept: {
  126. // icon: 'checkmark',
  127. // label: 'Accept',
  128. // callback: function(){ alert("Yes!"); }
  129. // },
  130. // cancel: {
  131. // icon: 'close',
  132. // label: 'Cancel',
  133. // callback: function(){ alert("No!"); }
  134. // }
  135. // });
  136. // Lungo.Notification.html("<h1 class='title'>Title</h1><article>aslkdkals</article><a href='#' class='button large anchor' >Seleccionar</a>", "Cancelar");
  137. // Lungo.Notification.push("Lorem ipsum dolor sit amet", "home");
  138. });