1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 05:20:56 +01:00
phorge-phorge/webroot/rsrc/js/application/conpherence/behavior-pontificate.js
Bob Trahan ddf97c0e8a Conpherence - Make the files widget more useful and ajaxify some more stuff
Summary: files widget updates as new files are added. made basically all edits "ajax" except for when you change the conpherence image which just does a reload. I will fix this in a future diff but it was starting to spiral out of control a bit.

Test Plan: commented on a task with files and noted the updated file widget. updated header image via drag and drop and dialogue -- noted a full reload. cropped image and re-titled conpherence - ajax updated as expected.

Reviewers: epriestley, chad

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2530

Differential Revision: https://secure.phabricator.com/D5288
2013-03-08 10:40:06 -08:00

67 lines
1.5 KiB
JavaScript

/**
* @provides javelin-behavior-conpherence-pontificate
* @requires javelin-behavior
* javelin-dom
* javelin-util
* javelin-workflow
*/
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)
);
// update the file widget
JX.DOM.setContent(
JX.$(config.file_widget),
JX.$H(r.file_widget)
);
// 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
);
});