1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-04 04:32:43 +01:00
phorge-phorge/webroot/rsrc/js/application/conpherence/behavior-pontificate.js
Bob Trahan 243b99f39e Conpherence - make pontificate be all ajaxy
Summary: serving up for some feedback -- does anything fancy need to happen when new messages load (say highlight em and fade the highlight out) or just scrolling down okay? in JS I have a TODO about how come it doesn't work; that code works okay in my console if I print out various debugging values and enter them in manually.

Test Plan: pontificate with myself; note new message and message entry updates properly. pontificate as different user then as myself; note two messages load and message entry updates properly. pontificate as a user who isn't the last to reply; note new message and message entry updates properly

Reviewers: epriestley, chad

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2522

Differential Revision: https://secure.phabricator.com/D5214
2013-03-05 15:45:36 -08:00

60 lines
1.3 KiB
JavaScript

/**
* @provides javelin-behavior-conpherence-pontificate
* @requires javelin-behavior
* javelin-dom
* javelin-request
*/
JX.behavior('conpherence-pontificate', function(config) {
var root = JX.$(config.form_pane);
var onsubmit = function(e) {
e.kill();
var form = JX.DOM.find(root, 'form');
JX.Workflow.newFromForm(form)
.setHandler(JX.bind(this, function(r) {
// add the new transactions, probably just our post but who knows
var messages = JX.$(config.messages);
JX.DOM.appendContent(messages, JX.$H(r.transactions));
messages.scrollTop = messages.scrollHeight;
// update the menu entry as well
JX.DOM.replace(
JX.$(r.conpherence_phid + '-nav-item'),
JX.$H(r.nav_item)
);
JX.DOM.replace(
JX.$(r.conpherence_phid + '-menu-item'),
JX.$H(r.menu_item)
);
// update the header
JX.DOM.setContent(
JX.$(config.header),
JX.$H(r.header)
);
// clear the textarea
var textarea = JX.DOM.find(form, 'textarea');
textarea.value = '';
}))
.start();
};
JX.DOM.listen(
root,
['submit', 'didSyntheticSubmit'],
null,
onsubmit
);
JX.DOM.listen(
root,
['click'],
'conpherence-pontificate',
onsubmit
);
});