You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

64 lines
1.3 KiB

  1. define([
  2. 'html!./template',
  3. 'css!./styles',
  4. 'ui/factory',
  5. 'js/generator',
  6. 'js/renderer',
  7. 'js/constants',
  8. 'js/client'
  9. ], function (
  10. template,
  11. styles,
  12. uiFactory,
  13. generator,
  14. renderer,
  15. constants,
  16. client
  17. ) {
  18. return {
  19. tpl: template,
  20. loaded: null,
  21. postRender: function () {
  22. if (constants.standAlone)
  23. this.find('.content > *:not(.btnNew):not(.btnImport):not(.btnExport)').addClass('disabled');
  24. this.on('.btnNew', 'click', this.actions.onNew.bind(this));
  25. this.on('.btnLoad', 'click', this.actions.onLoad.bind(this));
  26. this.on('.btnSave', 'click', this.actions.onSave.bind(this));
  27. this.on('.btnExport', 'click', this.actions.onExport.bind(this));
  28. this.on('.btnImport', 'click', this.actions.onImport.bind(this));
  29. this.on('.btnPersist', 'click', this.actions.onPersist.bind(this));
  30. },
  31. actions: {
  32. onNew: function () {
  33. this.loaded = null;
  34. generator.callAction('reset');
  35. renderer.makeDirty();
  36. },
  37. onLoad: function () {
  38. uiFactory.build('load');
  39. },
  40. onSave: function () {
  41. uiFactory.build('save');
  42. },
  43. onExport: function () {
  44. uiFactory.build('export');
  45. },
  46. onImport: function () {
  47. uiFactory.build('import');
  48. },
  49. onPersist: function () {
  50. client.persist(generator.getData());
  51. }
  52. }
  53. };
  54. });