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.
 
 
 

49 lines
902 B

  1. define([
  2. 'html!./template',
  3. 'css!./styles',
  4. 'js/generator',
  5. 'js/client'
  6. ], function (
  7. template,
  8. styles,
  9. generator,
  10. client
  11. ) {
  12. return {
  13. tpl: template,
  14. modal: true,
  15. centered: true,
  16. postRender: function () {
  17. this.on('.btnLoad', 'click', this.actions.onLoad.bind(this));
  18. client.getFileList(this.events.onGetFileList.bind(this));
  19. },
  20. actions: {
  21. onLoad: function (fileName) {
  22. client.load(fileName, generator.actions.load.bind(generator));
  23. this.destroy();
  24. }
  25. },
  26. events: {
  27. onGetFileList: function (list) {
  28. var el = this.find('.list').empty();
  29. list.forEach(function (l) {
  30. $('<div class="item">' + l + '</div>')
  31. .appendTo(el)
  32. .on('click', this.events.onClickItem.bind(this, l));
  33. }, this);
  34. },
  35. onClickItem: function (item) {
  36. this.actions.onLoad.call(this, item);
  37. $('.uiMenu').data('ui').loaded = item;
  38. }
  39. }
  40. }
  41. });