1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-12 08:36:13 +01:00
phorge-phorge/webroot/rsrc/js/application/conpherence/behavior-pontificate.js

49 lines
1.1 KiB
JavaScript
Raw Normal View History

/**
* @provides javelin-behavior-conpherence-pontificate
* @requires javelin-behavior
* javelin-dom
* javelin-util
* javelin-workflow
* javelin-stratcom
* conpherence-thread-manager
*/
JX.behavior('conpherence-pontificate', function() {
var _sendMessage = function(e) {
e.kill();
var form = e.getNode('tag:form');
var threadManager = JX.ConpherenceThreadManager.getInstance();
threadManager.sendMessage(form, {});
};
JX.Stratcom.listen(
['submit', 'didSyntheticSubmit'],
'conpherence-pontificate',
_sendMessage);
// Send on enter if the shift key is not held.
JX.Stratcom.listen(
'keydown',
'conpherence-pontificate',
function(e) {
if (e.getSpecialKey() != 'return') {
return;
}
var raw = e.getRawEvent();
if (raw.shiftKey) {
// If the shift key is pressed, let the browser write a newline into
// the textarea.
return;
}
// From here on, interpret this as a "send" action, not a literal
// newline.
e.kill();
_sendMessage(e);
});
});