events.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. });
  15. //Toggle Aside
  16. //Event on dinamic items
  17. lng.dom('#list-auto').on('swipeLeft', 'li', function(event){
  18. console.error(this, event, 'swipe');
  19. });
  20. //List.Append & List.prepend
  21. lng.dom('#test header a.red').tap(function(event) {
  22. var param = {
  23. el: '#list-added',
  24. template: 'profile-tmp',
  25. data: {
  26. name: 'Javier Jimenez Villar',
  27. description: '@soyjavi'
  28. }
  29. };
  30. if ($$(this).hasClass('prepend')) {
  31. lng.View.Template.List.append(param);
  32. } else {
  33. lng.View.Template.List.prepend(param);
  34. }
  35. });
  36. //Scroll.Append & Scroll.Last // Scroll.first & Scroll.last
  37. lng.dom('#test header a.green').tap(function(event) {
  38. lng.View.Scroll.append('scroll-horizontal', '<span>1</span>');
  39. lng.View.Scroll.first('scroll-horizontal');
  40. lng.View.Scroll.append('scroll-vertical', '<span>1</span>');
  41. lng.View.Scroll.last('scroll-vertical');
  42. });
  43. //Remove Item >> Scroll.refresh
  44. lng.dom('article#list-added li').tap(function(event) {
  45. $$(this).remove();
  46. lng.View.Scroll.refresh('list-added');
  47. });
  48. //SPECIAL
  49. $$('section#test').on('load', function(event) {
  50. console.error('Load #test', event);
  51. lng.Router.article('#next', '#files');
  52. });
  53. $$('section#test').on('unload', function(event) {
  54. console.error('Unload #test', event);
  55. });
  56. $$('article#art-2').on('load', function(event) {
  57. console.error('load article', this, event);
  58. });
  59. $$('article#art-1').on('unload', function(event) {
  60. console.error(LUNGO.Constants)
  61. console.error('unload article', this, event);
  62. });
  63. })(LUNGO);