body.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. BlazeComponent.extendComponent({
  2. template: function() {
  3. return 'boardComponent';
  4. },
  5. openNewListForm: function() {
  6. this.componentChildren('addlistForm')[0].open();
  7. },
  8. scrollLeft: function() {
  9. // TODO
  10. },
  11. onRendered: function() {
  12. var self = this;
  13. self.scrollLeft();
  14. if (Meteor.user().isBoardMember()) {
  15. self.$('.js-lists').sortable({
  16. tolerance: 'pointer',
  17. appendTo: '.js-lists',
  18. helper: 'clone',
  19. items: '.js-list:not(.add-list)',
  20. placeholder: 'list placeholder',
  21. start: function(event, ui) {
  22. $('.list.placeholder').height(ui.item.height());
  23. Popup.close();
  24. },
  25. stop: function() {
  26. self.$('.js-lists').find('.js-list:not(.add-list)').each(
  27. function(i, list) {
  28. var data = Blaze.getData(list);
  29. Lists.update(data._id, {
  30. $set: {
  31. sort: i
  32. }
  33. });
  34. }
  35. );
  36. }
  37. });
  38. // If there is no data in the board (ie, no lists) we autofocus the list
  39. // creation form by clicking on the corresponding element.
  40. if (self.data().lists().count() === 0) {
  41. this.openNewListForm();
  42. }
  43. }
  44. },
  45. sidebarSize: function() {
  46. var sidebar = this.componentChildren('boardSidebar')[0];
  47. if (Session.get('currentCard') !== null)
  48. return 'next-large-sidebar';
  49. else if (sidebar && sidebar.isOpen())
  50. return 'next-small-sidebar';
  51. }
  52. }).register('boardComponent');
  53. BlazeComponent.extendComponent({
  54. template: function() {
  55. return 'addlistForm';
  56. },
  57. // Proxy
  58. open: function() {
  59. this.componentChildren('inlinedForm')[0].open();
  60. }
  61. }).register('addlistForm');