2013-01-25 02:23:05 +01:00
|
|
|
/**
|
|
|
|
* @requires javelin-behavior
|
|
|
|
* javelin-dom
|
|
|
|
* javelin-stratcom
|
2013-03-26 21:30:35 +01:00
|
|
|
* javelin-workflow
|
|
|
|
* javelin-util
|
|
|
|
* phabricator-notification
|
|
|
|
* @provides javelin-behavior-conpherence-widget-pane
|
2013-01-25 02:23:05 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
JX.behavior('conpherence-widget-pane', function(config) {
|
|
|
|
|
|
|
|
JX.Stratcom.listen(
|
|
|
|
'click',
|
|
|
|
'conpherence-change-widget',
|
|
|
|
function(e) {
|
|
|
|
e.kill();
|
|
|
|
var data = e.getNodeData('conpherence-change-widget');
|
2013-03-13 21:03:51 +01:00
|
|
|
// abort if this widget isn't exactly involved in this toggle business
|
|
|
|
if (!config.widgetRegistery[data.widget]) {
|
|
|
|
return;
|
|
|
|
}
|
2013-01-25 02:23:05 +01:00
|
|
|
for (var widget in config.widgetRegistery) {
|
2013-03-13 21:03:51 +01:00
|
|
|
if (!config.widgetRegistery[widget]) {
|
|
|
|
continue;
|
|
|
|
} else if (widget == data.widget) {
|
2013-01-25 02:23:05 +01:00
|
|
|
JX.$(widget).style.display = 'block';
|
2013-02-05 04:01:46 +01:00
|
|
|
JX.DOM.alterClass(e.getTarget(), data.toggleClass, true);
|
2013-01-25 02:23:05 +01:00
|
|
|
} else {
|
|
|
|
JX.$(widget).style.display = 'none';
|
2013-02-05 04:01:46 +01:00
|
|
|
var cur_toggle = JX.$(widget + '-toggle');
|
|
|
|
JX.DOM.alterClass(
|
|
|
|
cur_toggle,
|
|
|
|
JX.Stratcom.getData(cur_toggle).toggleClass,
|
|
|
|
false
|
|
|
|
);
|
2013-01-25 02:23:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2013-04-02 18:32:40 +02:00
|
|
|
/* people widget */
|
2013-04-08 20:13:35 +02:00
|
|
|
JX.Stratcom.listen(
|
|
|
|
['submit', 'didSyntheticSubmit'],
|
2013-04-02 18:32:40 +02:00
|
|
|
'add-person',
|
|
|
|
function (e) {
|
|
|
|
e.kill();
|
2013-04-08 20:13:35 +02:00
|
|
|
var root = e.getNode('conpherence-layout');
|
|
|
|
var form = e.getNode('tag:form');
|
2013-04-02 18:32:40 +02:00
|
|
|
var data = e.getNodeData('add-person');
|
2013-04-08 20:13:35 +02:00
|
|
|
var peopleRoot = e.getNode('widgets-people');
|
|
|
|
var messages = JX.DOM.find(root, 'div', 'conpherence-messages');
|
|
|
|
var header = JX.DOM.find(root, 'div', 'conpherence-header');
|
|
|
|
var latestTransactionData = JX.Stratcom.getData(
|
|
|
|
JX.DOM.find(
|
|
|
|
root,
|
|
|
|
'input',
|
|
|
|
'latest-transaction-id'
|
|
|
|
));
|
|
|
|
data.latest_transaction_id = latestTransactionData.id;
|
2013-04-02 18:32:40 +02:00
|
|
|
JX.Workflow.newFromForm(form, data)
|
2013-04-08 20:13:35 +02:00
|
|
|
.setHandler(JX.bind(this, function (r) {
|
|
|
|
// update the transactions
|
|
|
|
JX.DOM.appendContent(messages, JX.$H(r.transactions));
|
|
|
|
messages.scrollTop = messages.scrollHeight;
|
|
|
|
|
|
|
|
try {
|
|
|
|
JX.DOM.replace(
|
|
|
|
JX.$(r.conpherence_phid + '-nav-item'),
|
|
|
|
JX.$H(r.nav_item));
|
|
|
|
JX.Stratcom.invoke(
|
|
|
|
'conpherence-selectthread',
|
|
|
|
null,
|
|
|
|
{ id : r.conpherence_phid + '-nav-item' }
|
|
|
|
);
|
|
|
|
} catch (ex) {
|
|
|
|
// Ignore; this view may not have a menu.
|
|
|
|
}
|
|
|
|
|
|
|
|
// update the header
|
|
|
|
JX.DOM.setContent(
|
|
|
|
header,
|
|
|
|
JX.$H(r.header)
|
|
|
|
);
|
|
|
|
|
|
|
|
// update the people widget
|
|
|
|
JX.DOM.setContent(
|
|
|
|
peopleRoot,
|
|
|
|
JX.$H(r.people_widget)
|
|
|
|
);
|
|
|
|
}))
|
2013-04-02 18:32:40 +02:00
|
|
|
.start();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2013-04-08 20:13:35 +02:00
|
|
|
JX.Stratcom.listen(
|
2013-04-02 18:32:40 +02:00
|
|
|
['click'],
|
|
|
|
'remove-person',
|
|
|
|
function (e) {
|
2013-04-08 20:13:35 +02:00
|
|
|
var peopleRoot = e.getNode('widgets-people');
|
2013-04-02 18:32:40 +02:00
|
|
|
var form = JX.DOM.find(peopleRoot, 'form');
|
|
|
|
var data = e.getNodeData('remove-person');
|
2013-04-08 20:13:35 +02:00
|
|
|
// we end up re-directing to conpherence home
|
2013-04-02 18:32:40 +02:00
|
|
|
JX.Workflow.newFromForm(form, data)
|
|
|
|
.start();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
/* settings widget */
|
2013-03-26 21:30:35 +01:00
|
|
|
var onsubmitSettings = function (e) {
|
|
|
|
e.kill();
|
2013-04-08 20:13:35 +02:00
|
|
|
var form = e.getNode('tag:form');
|
2013-03-26 21:30:35 +01:00
|
|
|
var button = JX.DOM.find(form, 'button');
|
|
|
|
JX.Workflow.newFromForm(form)
|
|
|
|
.setHandler(JX.bind(this, function (r) {
|
|
|
|
new JX.Notification()
|
|
|
|
.setDuration(6000)
|
|
|
|
.setContent(r)
|
|
|
|
.show();
|
|
|
|
button.disabled = '';
|
|
|
|
JX.DOM.alterClass(button, 'disabled', false);
|
|
|
|
}))
|
|
|
|
.start();
|
|
|
|
};
|
|
|
|
|
2013-04-08 20:13:35 +02:00
|
|
|
JX.Stratcom.listen(
|
|
|
|
['submit', 'didSyntheticSubmit'],
|
2013-03-26 21:30:35 +01:00
|
|
|
'notifications-update',
|
|
|
|
onsubmitSettings
|
|
|
|
);
|
|
|
|
|
2013-01-25 02:23:05 +01:00
|
|
|
});
|