sidebar.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. BlazeComponent.extendComponent({
  2. template: function() {
  3. return 'sidebar';
  4. },
  5. mixins: function() {
  6. return [Mixins.InfiniteScrolling, Mixins.PerfectScrollbar];
  7. },
  8. onCreated: function() {
  9. this._isOpen = new ReactiveVar(! Session.get('currentCard'));
  10. Sidebar = this;
  11. },
  12. isOpen: function() {
  13. return this._isOpen.get();
  14. },
  15. open: function() {
  16. if (! this._isOpen.get()) {
  17. this._isOpen.set(true);
  18. }
  19. },
  20. hide: function() {
  21. if (this._isOpen.get()) {
  22. this._isOpen.set(false);
  23. }
  24. },
  25. toogle: function() {
  26. this._isOpen.set(! this._isOpen.get());
  27. },
  28. calculateNextPeak: function() {
  29. var altitude = this.find('.js-board-sidebar-content').scrollHeight;
  30. this.callFirstWith(this, 'setNextPeak', altitude);
  31. },
  32. reachNextPeak: function() {
  33. var activitiesComponent = this.componentChildren('activities')[0];
  34. activitiesComponent.loadNextPage();
  35. },
  36. isTongueHidden: function() {
  37. return this.isOpen() && Filter.isActive();
  38. },
  39. onRendered: function() {
  40. var self = this;
  41. if (! Meteor.user().isBoardMember())
  42. return;
  43. $(document).on('mouseover', function() {
  44. self.$('.js-member,.js-label').draggable({
  45. appendTo: 'body',
  46. helper: 'clone',
  47. revert: 'invalid',
  48. revertDuration: 150,
  49. snap: false,
  50. snapMode: 'both',
  51. start: function() {
  52. Popup.close();
  53. }
  54. });
  55. });
  56. },
  57. events: function() {
  58. // XXX Hacky, we need some kind of `super`
  59. var mixinEvents = this.getMixin(Mixins.InfiniteScrolling).events();
  60. return mixinEvents.concat([{
  61. 'click .js-toogle-sidebar': this.toogle
  62. }]);
  63. }
  64. }).register('sidebar');