Commit 281d93eb authored by JC Brand's avatar JC Brand

Small improvements and bugfixes.

- Override the user_details.pt template to hide the user from the online
  contacts box.
- Add time to the chat messages.
parent 7d3c9829
...@@ -199,7 +199,10 @@ var xmppchat = (function ($, console) { ...@@ -199,7 +199,10 @@ var xmppchat = (function ($, console) {
that = this; that = this;
jarnxmpp.Presence.getUserInfo(user_id, function (data) { jarnxmpp.Presence.getUserInfo(user_id, function (data) {
var chat = $('#'+that.hash(jid)); var chat = $('#'+that.hash(jid)),
chat_content = chat.find(".chat-content"),
now = new Date(),
time = now.toLocaleTimeString().substring(0,5);
if (chat.length <= 0) { if (chat.length <= 0) {
chat = that.createChat(jid, 0); chat = that.createChat(jid, 0);
} }
...@@ -207,16 +210,15 @@ var xmppchat = (function ($, console) { ...@@ -207,16 +210,15 @@ var xmppchat = (function ($, console) {
chat.css('display','block'); chat.css('display','block');
that.reorderChats(); that.reorderChats();
} }
var chat_content = chat.find(".chat-content");
if (user_id == that.username) { if (user_id == that.username) {
message_html = '<div class="chat-message">' + message_html = '<div class="chat-message">' +
'<span class="chat-message-me">me:&nbsp;&nbsp;</span>' + '<span class="chat-message-me">'+time+' me:&nbsp;&nbsp;</span>' +
'<span class="chat-message-content">'+text+'</span>' + '<span class="chat-message-content">'+text+'</span>' +
'</div>'; '</div>';
} }
else { else {
message_html = '<div class="chat-message">' + message_html = '<div class="chat-message">' +
'<span class="chat-message-them">'+data.fullname+':&nbsp;&nbsp;</span>' + '<span class="chat-message-them">'+time+' '+data.fullname+':&nbsp;&nbsp;</span>' +
'<span class="chat-message-content">'+text+'</span>' + '<span class="chat-message-content">'+text+'</span>' +
'</div>'; '</div>';
} }
...@@ -234,7 +236,7 @@ var xmppchat = (function ($, console) { ...@@ -234,7 +236,7 @@ var xmppchat = (function ($, console) {
}); });
}; };
obj.closeChat = function (jid, audience) { obj.closeChat = function (jid) {
var chat_id = this.hash(jid); var chat_id = this.hash(jid);
jQuery('#'+chat_id).css('display','none'); jQuery('#'+chat_id).css('display','none');
xmppchat.reorderChats(); xmppchat.reorderChats();
...@@ -259,6 +261,9 @@ var xmppchat = (function ($, console) { ...@@ -259,6 +261,9 @@ var xmppchat = (function ($, console) {
}; };
obj.toggleChat = function (jid) { obj.toggleChat = function (jid) {
/* Minimize or maximize a chat box and record it in a cookie so that we
* remember the configuration after page loads.
*/
var chat_id = this.hash(jid), var chat_id = this.hash(jid),
minimized_chats = xmppchat.getMinimizedChats(), minimized_chats = xmppchat.getMinimizedChats(),
new_cookie; new_cookie;
...@@ -357,8 +362,7 @@ $(document).ready(function () { ...@@ -357,8 +362,7 @@ $(document).ready(function () {
xmppchat.chats.push('online-users-container'); xmppchat.chats.push('online-users-container');
}); });
$('a.user-details-toggle').live('click', function (e) { $('a.user-details-toggle').live('click', function (e) {
var userid = $(this).parent().attr('data-userid'), var $field = $('[name="message"]:input', $(this).parent()[0]),
$field = $('[name="message"]:input', $(this).parent()[0]),
recipient = $field.attr('data-recipient'); recipient = $field.attr('data-recipient');
xmppchat.startChat(recipient); xmppchat.startChat(recipient);
e.preventDefault(); e.preventDefault();
......
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