Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/webroot/rsrc/js/application/conpherence/behavior-participant-pane.js
12242 views
1
/**
2
* @requires javelin-behavior
3
* javelin-dom
4
* javelin-stratcom
5
* javelin-workflow
6
* javelin-util
7
* phabricator-notification
8
* conpherence-thread-manager
9
* @provides javelin-behavior-conpherence-participant-pane
10
*/
11
12
JX.behavior('conpherence-participant-pane', function() {
13
14
/**
15
* Generified adding new stuff to widgets technology!
16
*/
17
JX.Stratcom.listen(
18
['click'],
19
'conpherence-widget-adder',
20
function (e) {
21
e.kill();
22
23
var threadManager = JX.ConpherenceThreadManager.getInstance();
24
var href = threadManager._getUpdateURI();
25
var latest_transaction_id = threadManager.getLatestTransactionID();
26
var data = {
27
latest_transaction_id : latest_transaction_id,
28
action : 'add_person'
29
};
30
31
var workflow = new JX.Workflow(href, data)
32
.setHandler(function (r) {
33
var threadManager = JX.ConpherenceThreadManager.getInstance();
34
threadManager.setLatestTransactionID(r.latest_transaction_id);
35
var root = JX.DOM.find(document, 'div', 'conpherence-layout');
36
var messages = null;
37
try {
38
messages = JX.DOM.find(root, 'div', 'conpherence-messages');
39
} catch (ex) {
40
}
41
if (messages) {
42
JX.DOM.appendContent(messages, JX.$H(r.transactions));
43
JX.Stratcom.invoke('conpherence-redraw-thread', null, {});
44
}
45
46
try {
47
var people_root = JX.DOM.find(root, 'div', 'widgets-people');
48
// update the people widget
49
JX.DOM.setContent(
50
people_root,
51
JX.$H(r.people_widget));
52
} catch (ex) {
53
}
54
55
});
56
57
threadManager.syncWorkflow(workflow, 'submit');
58
}
59
);
60
61
JX.Stratcom.listen(
62
['touchstart', 'mousedown'],
63
'remove-person',
64
function (e) {
65
var threadManager = JX.ConpherenceThreadManager.getInstance();
66
var href = threadManager._getUpdateURI();
67
var data = e.getNodeData('remove-person');
68
69
// While the user is removing themselves, disable the notification
70
// update behavior. If we don't do this, the user can get an error
71
// when they remove themselves about permissions as the notification
72
// code tries to load what just happened.
73
var loadedPhid = threadManager.getLoadedThreadPHID();
74
threadManager.setLoadedThreadPHID(null);
75
76
new JX.Workflow(href, data)
77
.setCloseHandler(function() {
78
threadManager.setLoadedThreadPHID(loadedPhid);
79
})
80
// we re-direct to conpherence home so the thread manager will
81
// fix itself there
82
.setHandler(function(r) {
83
JX.$U(r.href).go();
84
})
85
.start();
86
}
87
);
88
89
/* settings widget */
90
var onsubmitSettings = function (e) {
91
e.kill();
92
var form = e.getNode('tag:form');
93
var button = JX.DOM.find(form, 'button');
94
JX.Workflow.newFromForm(form)
95
.setHandler(JX.bind(this, function (r) {
96
new JX.Notification()
97
.setDuration(6000)
98
.setContent(r)
99
.show();
100
button.disabled = '';
101
JX.DOM.alterClass(button, 'disabled', false);
102
}))
103
.start();
104
};
105
106
JX.Stratcom.listen(
107
['submit', 'didSyntheticSubmit'],
108
'notifications-update',
109
onsubmitSettings
110
);
111
112
});
113
114