view.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. <strong>{{name}}</strong>\
  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. <strong>{{name}}</strong>\
  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){
  23. var data = result;
  24. lng.Data.Cache.set('current_todo', data);
  25. $('#txtEditName').val(data.name);
  26. $('#txtEditDescription').val(data.description);
  27. $('#txtEditName').val(data.name);
  28. lng.Router.section('view');
  29. }
  30. });
  31. };
  32. var returnToMain = function(message, icon) {
  33. lng.Sugar.Growl.notify(message, 'Tap to close', icon, 'error', 5);
  34. //lng.Sugar.Growl.show(message, icon, true);
  35. App.Data.refresh();
  36. setTimeout(function() {
  37. lng.Router.back();
  38. lng.Sugar.Growl.hide();
  39. }, 1000);
  40. };
  41. var list = function(container, template, rows) {
  42. lng.View.Template.List.create({
  43. container_id: container,
  44. template_id: template,
  45. data: rows
  46. });
  47. };
  48. return{
  49. todo: todo,
  50. returnToMain: returnToMain,
  51. list: list
  52. }
  53. })(LUNGO, App);