1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
var defaultView = 'home';
Sidebar = null;
BlazeComponent.extendComponent({
template: function() {
return 'sidebar';
},
mixins: function() {
return [Mixins.InfiniteScrolling, Mixins.PerfectScrollbar];
},
onCreated: function() {
this._isOpen = new ReactiveVar(! Session.get('currentCard'));
this._view = new ReactiveVar(defaultView);
Sidebar = this;
},
onDestroyed: function() {
Sidebar = null;
},
isOpen: function() {
return this._isOpen.get();
},
open: function() {
if (! this._isOpen.get()) {
this._isOpen.set(true);
}
},
hide: function() {
if (this._isOpen.get()) {
this._isOpen.set(false);
}
},
toogle: function() {
this._isOpen.set(! this._isOpen.get());
},
calculateNextPeak: function() {
var altitude = this.find('.js-board-sidebar-content').scrollHeight;
this.callFirstWith(this, 'setNextPeak', altitude);
},
reachNextPeak: function() {
var activitiesComponent = this.componentChildren('activities')[0];
activitiesComponent.loadNextPage();
},
isTongueHidden: function() {
return this.isOpen() && this.getView() !== defaultView;
},
getView: function() {
return this._view.get();
},
setView: function(view) {
view = view || defaultView;
this._view.set(view);
},
getViewTemplate: function() {
return this.getView() + 'Sidebar';
},
// Board members can assign people or labels by drag-dropping elements from
// the sidebar to the cards on the board. In order to re-initialize the
// jquery-ui plugin any time a draggable member or label is modified or
// removed we use a autorun function and register a dependency on the both
// members and labels fields of the current board document.
onRendered: function() {
var self = this;
if (! Meteor.userId() || ! Meteor.user().isBoardMember())
return;
self.autorun(function() {
var currentBoardId = Tracker.nonreactive(function() {
return Session.get('currentBoard');
});
Boards.findOne(currentBoardId, {
fields: {
members: 1,
labels: 1
}
});
Tracker.afterFlush(function() {
self.$('.js-member,.js-label').draggable({
appendTo: 'body',
helper: 'clone',
revert: 'invalid',
revertDuration: 150,
snap: false,
snapMode: 'both',
start: function() {
EscapeActions.executeLowerThan('popup');
}
});
});
});
},
events: function() {
// XXX Hacky, we need some kind of `super`
var mixinEvents = this.getMixin(Mixins.InfiniteScrolling).events();
return mixinEvents.concat([{
'click .js-toogle-sidebar': this.toogle
}]);
}
}).register('sidebar');
EscapeActions.register('sidebarView',
function() { return Sidebar && Sidebar.getView() !== defaultView; },
function() { Sidebar.setView(defaultView); }
);
|