Commit 307e1f3f authored by Kristopher Ruzic's avatar Kristopher Ruzic

Add multiline support to messaging

use shift+enter to add newlines, and enter to send messages
parent 8bd33b5a
......@@ -239,16 +239,6 @@
var dateObject = new Date();\n
return dateObject.toUTCString(); \n
}\n
\n
$(document).ready(function() {\n
console.log("TEST");\n
$(\'#jabber-message\').keyup(function(e) {\n
if (e.which == 13 && ! e.shiftKey) {\n
$(this.form).submit();\n
return false;\n
}\n
});\n
});\n
\n
\n
function sequentialMessages(li, new_msg) { \n
......@@ -464,7 +454,7 @@
}\n
\n
function renderDialogPage(gadget, connection_gadget) {\n
var jid,\n
var jid, message_box,\n
contact_url;\n
return RSVP.Queue()\n
.push(function () {\n
......@@ -499,15 +489,32 @@
}\n
gadget.props.contact_dict[jid].read = true;\n
\n
function sendMessageHandler(submit_event) {\n
var text = submit_event.target[0].value;\n
submit_event.target[0].value = "";\n
return RSVP.all([\n
connection_gadget.sendMessage(jid, text),\n
updateConversation(gadget, jid, text, false)\n
]);\n
function sendMessageHandler(e) {\n
// don\'t send empty messages \n
if (!message_box.val().trim()) {\n
if (e.which === 13 && !e.shiftKey) {\n
e.preventDefault();\n
} \n
return true;\n
}\n
// send messages when the field is focused and Enter is pressed \n
if (e.which == 13 && !e.shiftKey && message_box.is(":focus")) {\n
e.preventDefault(); // prevent newline from being added before sending\n
var text = message_box.val();\n
message_box.val("");\n
return RSVP.all([\n
connection_gadget.sendMessage(jid, text),\n
updateConversation(gadget, jid, text, false)\n
]);\n
}\n
}\n
\n
\n
// add keypress listener to textarea\n
message_box = $(\'#jabber-message\');\n
message_box.on(\'keypress\', function(e) {\n
sendMessageHandler(e);\n
});\n
\n
return loopEventListener(\n
gadget.props.content_element.querySelector(\'form.message-form\'),\n
\'submit\',\n
......@@ -1065,7 +1072,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.49472.21975.11707</string> </value>
<value> <string>945.50924.44927.18978</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -1083,7 +1090,7 @@
</tuple>
<state>
<tuple>
<float>1442306131.67</float>
<float>1442393081.82</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment