view.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. App.View = (function(lng, App, undefined) {
  2. lng.View.Template.create('pending-tmp',
  3. '<li id="{{id}}">\
  4. <a href="#">\
  5. <span class="icon check"></span>\
  6. {{name}}\
  7. <small>{{description}}</small>\
  8. </a>\
  9. </li>'
  10. );
  11. lng.View.Template.create('list-tmp',
  12. '<li id="{{id}}">\
  13. <a href="#">\
  14. <span class="icon folder"></span>\
  15. {{name}}\
  16. <small>{{description}}</small>\
  17. </a>\
  18. </li>'
  19. );
  20. var todo = function(id) {
  21. lng.Data.Sql.select('todo', {id:id}, function(result){
  22. if (result.length > 0) {
  23. var data = result[0];
  24. lng.Data.Cache.set('current_todo', data);
  25. lng.dom('#txtEditName').val(data.name);
  26. lng.dom('#txtEditDescription').val(data.description);
  27. lng.dom('#txtEditName').val(data.name);
  28. lng.Router.section('view');
  29. }
  30. });
  31. };
  32. var returnToMain = function(message, icon) {
  33. lng.Sugar.Growl.show(message, 'Please wait...', icon, true, 2);
  34. App.Data.refresh();
  35. setTimeout(function() {
  36. lng.Router.back();
  37. lng.Sugar.Growl.hide();
  38. }, 2000);
  39. };
  40. var list = function(container, template, rows) {
  41. lng.View.Template.List.create({
  42. el: container,
  43. template: template,
  44. data: rows
  45. });
  46. lng.View.Element.count('a[href="' + container + '"]', rows.length);
  47. };
  48. return{
  49. todo: todo,
  50. returnToMain: returnToMain,
  51. list: list
  52. }
  53. })(Lungo, App);