events.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. App.Events = (function(lng, undefined) {
  2. lng.ready(function(){
  3. console.error('LUNGO.js is ready...');
  4. App.Services.mockProfiles();
  5. var homes = [
  6. {id: 1, name: 'lemoa'},
  7. {id: 2, name: 'zalla'}
  8. ];
  9. lng.View.Template.List.create({
  10. el: '#art-3',
  11. template: 'home-tmp',
  12. data: homes
  13. });
  14. setTimeout(function() {lng.View.Element.progress('.progress', 10, true, 'Downloading 1/5...');}, 500);
  15. setTimeout(function() {lng.View.Element.progress('.progress', 30, true, 'Downloading 2/5...');}, 1100);
  16. setTimeout(function() {lng.View.Element.progress('.progress', 40, true, 'Downloading 3/5...');}, 1600);
  17. setTimeout(function() {lng.View.Element.progress('.progress', 55, true, 'Downloading 4/5...');}, 1900);
  18. setTimeout(function() {lng.View.Element.progress('.progress', 70, true, 'Downloading 5/5...');}, 2200);
  19. setTimeout(function() {lng.View.Element.progress('.progress', 100, true, 'Finished.');}, 3000);
  20. });
  21. //Toggle Aside
  22. //Event on dinamic items
  23. lng.dom('#list-auto').on('swipeLeft', 'li', function(event){
  24. console.error(this, event, 'swipe');
  25. });
  26. //List.Append & List.prepend
  27. lng.dom('#test header a.red').tap(function(event) {
  28. var param = {
  29. el: '#list-added',
  30. template: 'profile-tmp',
  31. data: {
  32. name: 'Javier Jimenez Villar',
  33. description: '@soyjavi'
  34. }
  35. };
  36. if ($$(this).hasClass('prepend')) {
  37. lng.View.Template.List.append(param);
  38. } else {
  39. lng.View.Template.List.prepend(param);
  40. }
  41. });
  42. //Scroll.Append & Scroll.Last // Scroll.first & Scroll.last
  43. lng.dom('#test header a.green').tap(function(event) {
  44. lng.View.Scroll.append('scroll-horizontal', '<span>1</span>');
  45. lng.View.Scroll.first('scroll-horizontal');
  46. lng.View.Scroll.append('scroll-vertical', '<span>1</span>');
  47. lng.View.Scroll.last('scroll-vertical');
  48. });
  49. //Remove Item >> Scroll.refresh
  50. lng.dom('article#list-added li').tap(function(event) {
  51. $$(this).remove();
  52. lng.View.Scroll.refresh('list-added');
  53. });
  54. //SPECIAL
  55. $$('section#test').on('load', function(event) {
  56. console.error('Load #test', event);
  57. lng.Router.article('#next', '#files');
  58. });
  59. $$('section#test').on('unload', function(event) {
  60. console.error('Unload #test', event);
  61. });
  62. $$('article#art-2').on('load', function(event) {
  63. console.error('load article', this, event);
  64. });
  65. $$('article#art-1').on('unload', function(event) {
  66. console.error(LUNGO.Constants)
  67. console.error('unload article', this, event);
  68. });
  69. })(LUNGO);