2013-03-06 00:45:36 +01:00
|
|
|
/**
|
|
|
|
* @provides javelin-behavior-conpherence-pontificate
|
|
|
|
* @requires javelin-behavior
|
|
|
|
* javelin-dom
|
2013-03-08 19:40:06 +01:00
|
|
|
* javelin-util
|
|
|
|
* javelin-workflow
|
2013-03-31 23:41:13 +02:00
|
|
|
* javelin-stratcom
|
2013-03-06 00:45:36 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
JX.behavior('conpherence-pontificate', function(config) {
|
|
|
|
var onsubmit = function(e) {
|
|
|
|
e.kill();
|
2013-03-31 23:41:13 +02:00
|
|
|
|
|
|
|
var form = e.getNode('tag:form');
|
|
|
|
|
|
|
|
var root = e.getNode('conpherence-layout');
|
|
|
|
var messages = JX.DOM.find(root, 'div', 'conpherence-messages');
|
|
|
|
var header = JX.DOM.find(root, 'div', 'conpherence-header');
|
2013-04-08 20:13:35 +02:00
|
|
|
var fileWidget = null;
|
|
|
|
try {
|
|
|
|
fileWidget = JX.DOM.find(root, 'div', 'widgets-files');
|
|
|
|
} catch (ex) {
|
|
|
|
// Ignore; maybe no files widget
|
|
|
|
}
|
2013-04-08 22:41:34 +02:00
|
|
|
var peopleWidget = null;
|
|
|
|
try {
|
|
|
|
peopleWidget = JX.DOM.find(root, 'div', 'widgets-people');
|
|
|
|
} catch (ex) {
|
|
|
|
// Ignore; maybe no peoples widget
|
|
|
|
}
|
2013-03-31 23:41:13 +02:00
|
|
|
|
2013-03-06 00:45:36 +01:00
|
|
|
JX.Workflow.newFromForm(form)
|
|
|
|
.setHandler(JX.bind(this, function(r) {
|
|
|
|
// add the new transactions, probably just our post but who knows
|
|
|
|
JX.DOM.appendContent(messages, JX.$H(r.transactions));
|
|
|
|
messages.scrollTop = messages.scrollHeight;
|
2013-03-31 23:41:13 +02:00
|
|
|
JX.DOM.setContent(header, JX.$H(r.header));
|
|
|
|
|
|
|
|
try {
|
2013-04-08 20:13:35 +02:00
|
|
|
var node = JX.$(r.conpherence_phid + '-nav-item');
|
2013-03-31 23:41:13 +02:00
|
|
|
JX.DOM.replace(
|
2013-04-08 20:13:35 +02:00
|
|
|
node,
|
2013-03-31 23:41:13 +02:00
|
|
|
JX.$H(r.nav_item));
|
2013-04-08 20:13:35 +02:00
|
|
|
JX.Stratcom.invoke(
|
|
|
|
'conpherence-selectthread',
|
|
|
|
null,
|
|
|
|
{ id : r.conpherence_phid + '-nav-item' }
|
|
|
|
);
|
2013-03-31 23:41:13 +02:00
|
|
|
} catch (ex) {
|
|
|
|
// Ignore; this view may not have a menu.
|
|
|
|
}
|
|
|
|
|
2013-04-08 20:13:35 +02:00
|
|
|
if (fileWidget) {
|
|
|
|
JX.DOM.setContent(
|
|
|
|
fileWidget,
|
|
|
|
JX.$H(r.file_widget)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-04-08 22:41:34 +02:00
|
|
|
if (peopleWidget) {
|
|
|
|
JX.DOM.setContent(
|
|
|
|
peopleWidget,
|
|
|
|
JX.$H(r.people_widget)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-04-02 20:27:58 +02:00
|
|
|
var inputs = JX.DOM.scry(form, 'input');
|
|
|
|
for (var ii = 0; ii < inputs.length; ii++) {
|
|
|
|
if (inputs[ii].name == 'latest_transaction_id') {
|
|
|
|
inputs[ii].value = r.latest_transaction_id;
|
|
|
|
break;
|
|
|
|
}
|
2013-03-31 23:41:13 +02:00
|
|
|
}
|
2013-03-06 00:45:36 +01:00
|
|
|
|
|
|
|
var textarea = JX.DOM.find(form, 'textarea');
|
|
|
|
textarea.value = '';
|
|
|
|
}))
|
|
|
|
.start();
|
|
|
|
};
|
|
|
|
|
2013-03-31 23:41:33 +02:00
|
|
|
JX.Stratcom.listen(
|
|
|
|
['submit', 'didSyntheticSubmit'],
|
|
|
|
'conpherence-pontificate',
|
|
|
|
onsubmit);
|
2013-03-06 00:45:36 +01:00
|
|
|
|
|
|
|
});
|