1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-21 01:38:48 +02:00
phorge-phorge/webroot/rsrc/js/application/conpherence/behavior-pontificate.js
epriestley 9db4feda09 Further corrections to Conpherence updates
Summary:
Apparently I am crazy and didn't test D5537 propertly at all. In particular:

  - Currently, the update sends back new "people" and "files" widgets. The "people" widget has a tokenizer, which fatals when the behavior initializes without the widget in the DOM. For now, disable widget updates on replies. I'll fix this in a future diff.
  - Currently, we don't update the "last_transaction_id" in the form itself, so the first reply sends back 1 message, the next 2 messages, etc. Update the input.
  - The transaction paging doesn't and has never worked, I am crazy. Make it actually work.

Test Plan:
computers are too hard

(also, this is why I hate Javascript)

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D5538
2013-04-02 11:27:58 -07:00

55 lines
1.5 KiB
JavaScript

/**
* @provides javelin-behavior-conpherence-pontificate
* @requires javelin-behavior
* javelin-dom
* javelin-util
* javelin-workflow
* javelin-stratcom
*/
JX.behavior('conpherence-pontificate', function(config) {
var onsubmit = function(e) {
e.kill();
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');
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;
JX.DOM.setContent(header, JX.$H(r.header));
try {
JX.DOM.replace(
JX.$(r.conpherence_phid + '-nav-item'),
JX.$H(r.nav_item));
} catch (ex) {
// Ignore; this view may not have a menu.
}
var inputs = JX.DOM.scry(form, 'input');
for (var ii = 0; ii < inputs.length; ii++) {
JX.log(inputs[ii]);
if (inputs[ii].name == 'latest_transaction_id') {
inputs[ii].value = r.latest_transaction_id;
break;
}
}
var textarea = JX.DOM.find(form, 'textarea');
textarea.value = '';
}))
.start();
};
JX.Stratcom.listen(
['submit', 'didSyntheticSubmit'],
'conpherence-pontificate',
onsubmit);
});