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 @@ ...@@ -239,16 +239,6 @@
var dateObject = new Date();\n var dateObject = new Date();\n
return dateObject.toUTCString(); \n return dateObject.toUTCString(); \n
}\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
\n \n
function sequentialMessages(li, new_msg) { \n function sequentialMessages(li, new_msg) { \n
...@@ -464,7 +454,7 @@ ...@@ -464,7 +454,7 @@
}\n }\n
\n \n
function renderDialogPage(gadget, connection_gadget) {\n function renderDialogPage(gadget, connection_gadget) {\n
var jid,\n var jid, message_box,\n
contact_url;\n contact_url;\n
return RSVP.Queue()\n return RSVP.Queue()\n
.push(function () {\n .push(function () {\n
...@@ -499,15 +489,32 @@ ...@@ -499,15 +489,32 @@
}\n }\n
gadget.props.contact_dict[jid].read = true;\n gadget.props.contact_dict[jid].read = true;\n
\n \n
function sendMessageHandler(submit_event) {\n function sendMessageHandler(e) {\n
var text = submit_event.target[0].value;\n // don\'t send empty messages \n
submit_event.target[0].value = "";\n if (!message_box.val().trim()) {\n
return RSVP.all([\n if (e.which === 13 && !e.shiftKey) {\n
connection_gadget.sendMessage(jid, text),\n e.preventDefault();\n
updateConversation(gadget, jid, text, false)\n } \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 \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 return loopEventListener(\n
gadget.props.content_element.querySelector(\'form.message-form\'),\n gadget.props.content_element.querySelector(\'form.message-form\'),\n
\'submit\',\n \'submit\',\n
...@@ -1065,7 +1072,7 @@ ...@@ -1065,7 +1072,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>945.49472.21975.11707</string> </value> <value> <string>945.50924.44927.18978</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -1083,7 +1090,7 @@ ...@@ -1083,7 +1090,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1442306131.67</float> <float>1442393081.82</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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