Commit fc14aa9db100213a7713d72cc4106d8796c7b3c4

Authored by Rodrigo Souto
1 parent 46ac0b54

Major refactoring on chat interface

app/helpers/chat_helper.rb
@@ -6,8 +6,9 @@ module ChatHelper @@ -6,8 +6,9 @@ module ChatHelper
6 ['icon-menu-busy', _('Busy'), 'chat-busy'], 6 ['icon-menu-busy', _('Busy'), 'chat-busy'],
7 ['icon-menu-offline', _('Sign out of chat'), 'chat-disconnect'], 7 ['icon-menu-offline', _('Sign out of chat'), 'chat-disconnect'],
8 ] 8 ]
  9 + avatar = profile_image(user, :portrait, :class => 'avatar')
9 content_tag('span', 10 content_tag('span',
10 - link_to(content_tag('span', user.name) + ui_icon('ui-icon-triangle-1-s'), 11 + link_to(avatar + content_tag('span', user.name) + ui_icon('ui-icon-triangle-1-s'),
11 '#', 12 '#',
12 :onclick => 'toggleMenu(this); return false', 13 :onclick => 'toggleMenu(this); return false',
13 :class => icon_class + ' simplemenu-trigger' 14 :class => icon_class + ' simplemenu-trigger'
app/views/shared/logged_in/xmpp_chat.html.erb
@@ -13,13 +13,9 @@ @@ -13,13 +13,9 @@
13 </script> 13 </script>
14 14
15 <div id='chat'> 15 <div id='chat'>
16 - <div class='header'>  
17 - <%= _("Chat %s") % environment.name %>  
18 - </div>  
19 <div id='buddy-list'> 16 <div id='buddy-list'>
20 <div class='toolbar'> 17 <div class='toolbar'>
21 <div id='user-status'> 18 <div id='user-status'>
22 - <%= profile_image(user, :portrait, :class => 'avatar') %>  
23 <%= user_status_menu('icon-menu-offline', _('Offline')) %> 19 <%= user_status_menu('icon-menu-offline', _('Offline')) %>
24 </div> 20 </div>
25 <div class='dialog-error' style='display: none'></div> 21 <div class='dialog-error' style='display: none'></div>
@@ -39,22 +35,19 @@ @@ -39,22 +35,19 @@
39 <div id='conversations'></div> 35 <div id='conversations'></div>
40 </div> 36 </div>
41 37
42 - <div id="chat-templates"> 38 + <div id="chat-templates" style="display: none;">
43 39
44 - <div class="conversation-template">  
45 - <div class='conversation' style="display: none;">  
46 - <div class="header">  
47 - <span class="chat-target">  
48 - <img class="avatar">  
49 - <span class="other-name"></span>  
50 - </span>  
51 - <a href="" class="back"><%= _('Back') %></a>  
52 - </div>  
53 - <div class='history'></div>  
54 - <div class='input-div'>  
55 - <div class='icon-chat'></div>  
56 - <textarea class='input'></textarea>  
57 - </div> 40 + <div class="conversation">
  41 + <div class="conversation-header">
  42 + <span class="chat-target">
  43 + <img class="avatar">
  44 + <span class="other-name"></span>
  45 + </span>
  46 + </div>
  47 + <div class='history'></div>
  48 + <div class='input-div'>
  49 + <div class='icon-chat'></div>
  50 + <textarea class='input'></textarea>
58 </div> 51 </div>
59 </div> 52 </div>
60 53
@@ -86,12 +79,11 @@ @@ -86,12 +79,11 @@
86 79
87 <div class="message"> 80 <div class="message">
88 <div data-who="%{who}" class="message %{who}"> 81 <div data-who="%{who}" class="message %{who}">
89 - <div class="author">  
90 - %{avatar}  
91 - <h5 class="%{who}-name">%{name}</h5>  
92 - </div>  
93 <div class="content"> 82 <div class="content">
94 <span class="time" title="%{time}"></span> 83 <span class="time" title="%{time}"></span>
  84 + <div class="author">
  85 + %{avatar}
  86 + </div>
95 <p>%{message}</p> 87 <p>%{message}</p>
96 </div> 88 </div>
97 </div> 89 </div>
public/designs/themes/noosfero/style.css
@@ -9,11 +9,6 @@ @@ -9,11 +9,6 @@
9 #title-bar { 9 #title-bar {
10 background-color: gray; 10 background-color: gray;
11 } 11 }
12 -#buddy-list .toolbar {  
13 - background-color: gray;  
14 - border-top: 1px solid;  
15 - border-bottom: 1px solid;  
16 -}  
17 #title-bar h1 { 12 #title-bar h1 {
18 color: white; 13 color: white;
19 } 14 }
public/javascripts/chat.js
@@ -65,7 +65,7 @@ jQuery(function($) { @@ -65,7 +65,7 @@ jQuery(function($) {
65 }, 65 },
66 insert_or_update_group: function (jid, presence) { 66 insert_or_update_group: function (jid, presence) {
67 var jid_id = Jabber.jid_to_id(jid); 67 var jid_id = Jabber.jid_to_id(jid);
68 - var list = $('#buddy-list .buddies .online'); 68 + var list = $('#buddy-list .buddies ul.online');
69 var item = $('#' + jid_id); 69 var item = $('#' + jid_id);
70 presence = presence || ($(item).length > 0 ? $(item).parent('li').attr('class') : 'offline'); 70 presence = presence || ($(item).length > 0 ? $(item).parent('li').attr('class') : 'offline');
71 log('adding or updating contact ' + jid + ' as ' + presence); 71 log('adding or updating contact ' + jid + ' as ' + presence);
@@ -78,7 +78,7 @@ jQuery(function($) { @@ -78,7 +78,7 @@ jQuery(function($) {
78 var jid_id = Jabber.jid_to_id(jid); 78 var jid_id = Jabber.jid_to_id(jid);
79 var item = $('#' + jid_id); 79 var item = $('#' + jid_id);
80 presence = presence || ($(item).length > 0 ? $(item).parent('li').attr('class') : 'offline'); 80 presence = presence || ($(item).length > 0 ? $(item).parent('li').attr('class') : 'offline');
81 - var list = $('#buddy-list .buddies ' + (presence=='offline' ? '.offline' : '.online')); 81 + var list = $('#buddy-list .buddies ul' + (presence=='offline' ? '.offline' : '.online'));
82 82
83 log('adding or updating contact ' + jid + ' as ' + presence); 83 log('adding or updating contact ' + jid + ' as ' + presence);
84 Jabber.insert_or_update_user(list, item, jid, name, presence, Jabber.template('.buddy-item'), 'chat'); 84 Jabber.insert_or_update_user(list, item, jid, name, presence, Jabber.template('.buddy-item'), 'chat');
@@ -535,7 +535,8 @@ jQuery(function($) { @@ -535,7 +535,8 @@ jQuery(function($) {
535 535
536 conversation.find('.conversation').show(); 536 conversation.find('.conversation').show();
537 count_unread_messages(jid_id, true); 537 count_unread_messages(jid_id, true);
538 - recent_messages(Jabber.jid_of(jid_id)); 538 + if(conversation.find('#chat-offset-container-0').length == 0)
  539 + recent_messages(Jabber.jid_of(jid_id));
539 conversation.find('.conversation .input-div textarea.input').focus(); 540 conversation.find('.conversation .input-div textarea.input').focus();
540 }); 541 });
541 542
@@ -551,14 +552,6 @@ jQuery(function($) { @@ -551,14 +552,6 @@ jQuery(function($) {
551 $('.conversation textarea:visible').focus(); 552 $('.conversation textarea:visible').focus();
552 }); 553 });
553 554
554 - $('#chat .conversation .back').live('click', function() {  
555 - $('#chat #chat-window .conversation').hide();  
556 - });  
557 -  
558 - $('#chat .toolbar .back').live('click', function() {  
559 - $('#chat').hide('fast');  
560 - });  
561 -  
562 function create_conversation_tab(title, jid_id) { 555 function create_conversation_tab(title, jid_id) {
563 var conversation_id = Jabber.conversation_prefix + jid_id; 556 var conversation_id = Jabber.conversation_prefix + jid_id;
564 var conversation = $('#' + conversation_id); 557 var conversation = $('#' + conversation_id);
@@ -569,9 +562,7 @@ jQuery(function($) { @@ -569,9 +562,7 @@ jQuery(function($) {
569 var jid = Jabber.jid_of(jid_id); 562 var jid = Jabber.jid_of(jid_id);
570 var identifier = getIdentifier(jid); 563 var identifier = getIdentifier(jid);
571 564
572 - // opening chat with selected online friend  
573 - var panel = $('<div id="'+conversation_id +'"></div>').appendTo($conversations);  
574 - panel.append(Jabber.template('.conversation-template')); 565 + var panel = $('#chat-templates .conversation').clone().appendTo($conversations).attr('id', conversation_id);
575 panel.find('.chat-target .avatar').replaceWith(getAvatar(identifier)); 566 panel.find('.chat-target .avatar').replaceWith(getAvatar(identifier));
576 panel.find('.chat-target .other-name').html(title); 567 panel.find('.chat-target .other-name').html(title);
577 $('#chat .history').perfectScrollbar(); 568 $('#chat .history').perfectScrollbar();
public/stylesheets/chat.css
@@ -10,17 +10,49 @@ @@ -10,17 +10,49 @@
10 box-shadow: -3px 0px 5px #888; 10 box-shadow: -3px 0px 5px #888;
11 } 11 }
12 12
  13 +#chat-window {
  14 + height: 100%;
  15 + position: relative;
  16 +}
  17 +
13 #chat #buddy-list { 18 #chat #buddy-list {
14 background-color: #f9f9f9; 19 background-color: #f9f9f9;
15 - width: 175px;  
16 - height: 75%;  
17 - overflow: hidden;  
18 - position: absolute; 20 + top: 0;
19 right: 0; 21 right: 0;
  22 + width: 65px;
  23 + bottom: 100px;
  24 + position: absolute;
20 border-left: 1px solid #DCE4E7; 25 border-left: 1px solid #DCE4E7;
21 border-bottom: 1px solid #DCE4E7; 26 border-bottom: 1px solid #DCE4E7;
  27 + z-index: 2;
  28 + transition: width 0.3s ease-in;
22 } 29 }
  30 +
  31 +#chat #buddy-list:hover {
  32 + width: 190px;
  33 + transition: width 0.3s ease-in;
  34 +}
  35 +
23 #buddy-list .buddies { 36 #buddy-list .buddies {
  37 + position: absolute;
  38 + bottom: 0;
  39 + top: 25px;
  40 + right: 6px;
  41 + left: 7px;
  42 + bottom: 7px;
  43 + overflow: hidden;
  44 + white-space: nowrap;
  45 + transition: all 0.3s ease-in;
  46 +}
  47 +
  48 +#buddy-list:hover .buddies {
  49 + top: 57px;
  50 + left: 15px;
  51 + right: 15px;
  52 + transition: all 0.3s ease-in;
  53 +}
  54 +
  55 +#buddy-list .buddies ul {
24 list-style-type: none; 56 list-style-type: none;
25 padding: 0; 57 padding: 0;
26 margin: 0; 58 margin: 0;
@@ -53,10 +85,10 @@ @@ -53,10 +85,10 @@
53 vertical-align: middle; 85 vertical-align: middle;
54 } 86 }
55 #chat #buddy-list .toolbar { 87 #chat #buddy-list .toolbar {
56 - border: 0;  
57 height: 45px; 88 height: 45px;
58 - background-color: rgb(39, 39, 39);  
59 - border-bottom: 1px solid #383838; 89 + width: 100%;
  90 + background-color: #bbbeb7;
  91 + display: table;
60 } 92 }
61 #buddy-list .toolbar .dialog-error { 93 #buddy-list .toolbar .dialog-error {
62 position: absolute; 94 position: absolute;
@@ -73,35 +105,44 @@ @@ -73,35 +105,44 @@
73 margin: 0 0 5px 0; 105 margin: 0 0 5px 0;
74 } 106 }
75 107
76 -  
77 #buddy-list .body{ 108 #buddy-list .body{
78 - position: relative;  
79 - padding: 5px; 109 + position: absolute;
  110 + bottom: 0;
  111 + right: 0;
  112 + left: 0;
  113 + top: 20px;
  114 + padding: 15px;
  115 + transition: top 0.3s ease-in;
  116 +}
  117 +
  118 +#buddy-list:hover .body{
  119 + top: 45px;
  120 + transition: top 0.3s ease-in;
80 } 121 }
81 122
82 #buddy-list .search{ 123 #buddy-list .search{
83 - width: 150px;  
84 - padding: 7px;  
85 - color: #FFF;  
86 - background-color: #BABDB6; 124 + width: 142px;
  125 + padding: 0;
  126 + height: 0;
  127 + color: #000;
  128 + background-color: #dee1da;
87 border: 0; 129 border: 0;
88 - margin-bottom: 5px; 130 + transition: all 0.2s ease-in;
89 } 131 }
90 132
91 -.conversation {  
92 - background-color: #303030;  
93 - height: 100%;  
94 - position: absolute;  
95 - width: 100%;  
96 - top: 0;  
97 - right: 0; 133 +#buddy-list:hover .search{
  134 + transition: all 0.3s ease-in 0.3;
  135 + height: 16px;
  136 + padding: 9px;
98 } 137 }
  138 +
99 .conversation .input-div { 139 .conversation .input-div {
100 position: absolute; 140 position: absolute;
101 right: 0; 141 right: 0;
  142 + left: 0;
102 bottom: 0; 143 bottom: 0;
103 - padding: 0 20px 15px 15px;  
104 - border-top: 1px solid rgb(65, 65, 65); 144 + height: 80px;
  145 + padding: 20px 15px 31px 7px;
105 } 146 }
106 .msie7 .conversation .input-div { 147 .msie7 .conversation .input-div {
107 padding-left: 5px; 148 padding-left: 5px;
@@ -118,20 +159,17 @@ @@ -118,20 +159,17 @@
118 left: 20px; 159 left: 20px;
119 } 160 }
120 .conversation textarea { 161 .conversation textarea {
121 - height: 60px;  
122 - padding-left: 25px; 162 + height: 100%;
  163 + width: 100%;
123 overflow: auto; 164 overflow: auto;
124 } 165 }
125 -.conversation .history { 166 +#conversations .history {
  167 + overflow: hidden;
126 position: absolute; 168 position: absolute;
127 - right: 0;  
128 - top: 40px; 169 + right: 66px;
  170 + left: 0;
  171 + top: 45px;
129 bottom: 100px; 172 bottom: 100px;
130 - overflow: hidden;  
131 - width: 100%;  
132 -}  
133 -.msie7 #chat-window .conversation .history {  
134 - overflow-x: hidden;  
135 } 173 }
136 #chat .unread-messages { 174 #chat .unread-messages {
137 float: right; 175 float: right;
@@ -143,38 +181,49 @@ @@ -143,38 +181,49 @@
143 padding: 10px 8px 10px 6px; 181 padding: 10px 8px 10px 6px;
144 clear: both; 182 clear: both;
145 } 183 }
  184 +
  185 +#chat-window .history .message.self .time {
  186 + color: #888a85;
  187 +}
  188 +
146 #chat-window .history .message .time { 189 #chat-window .history .message .time {
147 float: right; 190 float: right;
148 - color: rgb(184, 184, 184); 191 + color: white;
149 font-style: italic; 192 font-style: italic;
150 font-size: 10px; 193 font-size: 10px;
151 - border-bottom: 1px solid rgba(255, 255, 255, 0.1); 194 + border-bottom: 1px solid #d3d7cf;
152 width: 100%; 195 width: 100%;
153 text-align: right; 196 text-align: right;
  197 + margin-bottom: 5px;
154 } 198 }
155 #chat-window .history .message h5, #chat-window .history .message p { 199 #chat-window .history .message h5, #chat-window .history .message p {
156 margin: 0; 200 margin: 0;
157 } 201 }
158 #chat-window .history .message p { 202 #chat-window .history .message p {
159 - max-width: 100%;  
160 overflow: auto; 203 overflow: auto;
161 - clear: both; 204 + margin-left: 40px;
  205 +}
  206 +
  207 +#chat-window .history .message.self p {
  208 + margin-left: 1px;
162 } 209 }
163 210
164 #chat-window .history .message .content { 211 #chat-window .history .message .content {
165 - background-color: #257CAD;  
166 - color: rgb(223, 223, 223);  
167 - padding: 5px; 212 + background-color: #bbbeb7;
  213 + color: white;;
  214 + padding: 8px;
168 border-radius: 5px; 215 border-radius: 5px;
169 display: inline-block; 216 display: inline-block;
170 - width: 74%; 217 + width: 248px;
  218 + font-size: 15px;
171 } 219 }
172 #chat-window .history .message .content a { 220 #chat-window .history .message .content a {
173 color: rgb(108, 226, 255); 221 color: rgb(108, 226, 255);
174 text-decoration: none; 222 text-decoration: none;
175 } 223 }
176 #chat-window .history .message.self .content { 224 #chat-window .history .message.self .content {
177 - background-color: #383838; 225 + background-color: #f9f9f9;
  226 + color: #888a85;
178 } 227 }
179 228
180 #chat-window .history .message .avatar { 229 #chat-window .history .message .avatar {
@@ -240,6 +289,32 @@ div.occupants &gt; a.up { @@ -240,6 +289,32 @@ div.occupants &gt; a.up {
240 #chat .title-bar a { 289 #chat .title-bar a {
241 text-decoration: none; 290 text-decoration: none;
242 } 291 }
  292 +
  293 +#conversations {
  294 + height: 100%;
  295 +}
  296 +
  297 +#conversations .conversation {
  298 + height: 100%;
  299 + position: relative;
  300 +}
  301 +
  302 +#chat-window #conversations .conversation-header {
  303 + position: absolute;
  304 + right: 0;
  305 + left: 0;
  306 + background-color: #2e3436;
  307 + color: white;
  308 + width: 284px;
  309 + height: 45px;
  310 + font-size: 18px;
  311 + text-align: center;
  312 +}
  313 +
  314 +#user-status .avatar {
  315 + margin-left: 4px;
  316 +}
  317 +
243 .title-bar .title { 318 .title-bar .title {
244 margin: 0; 319 margin: 0;
245 font-size: 12px; 320 font-size: 12px;
@@ -259,10 +334,8 @@ div.occupants &gt; a.up { @@ -259,10 +334,8 @@ div.occupants &gt; a.up {
259 height: 40px; 334 height: 40px;
260 background-color: rgb(39, 39, 39); 335 background-color: rgb(39, 39, 39);
261 } 336 }
262 -.conversation .header .chat-target {  
263 - padding: 0px 6px 0 6px;  
264 - display: inline-block;  
265 - max-width: 70%; 337 +.conversation-header .chat-target {
  338 + line-height: 45px;
266 } 339 }
267 .conversation .header .other-name { 340 .conversation .header .other-name {
268 color: rgb(238, 238, 238); 341 color: rgb(238, 238, 238);
@@ -278,14 +351,15 @@ div.occupants &gt; a.up { @@ -278,14 +351,15 @@ div.occupants &gt; a.up {
278 color: white; 351 color: white;
279 } 352 }
280 #chat #chat-window .other-name, #chat #chat-window .history .self-name, #chat #chat-window .history h5, #chat .toolbar #user-status span.other-name { 353 #chat #chat-window .other-name, #chat #chat-window .history .self-name, #chat #chat-window .history h5, #chat .toolbar #user-status span.other-name {
281 - color: #257CAD; 354 + color: white;
282 overflow: hidden; 355 overflow: hidden;
283 - display: inline-block;  
284 max-width: 140px; 356 max-width: 140px;
  357 + line-height: 33px;
285 } 358 }
286 #chat .toolbar #user-status span, #chat #conversations .header .chat-target span { 359 #chat .toolbar #user-status span, #chat #conversations .header .chat-target span {
287 max-width: 140px; 360 max-width: 140px;
288 - color: rgb(238, 238, 238); 361 + font-weight: 900;
  362 + color: white;
289 display: inline-block 363 display: inline-block
290 } 364 }
291 #chat #chat-window .history h5 { 365 #chat #chat-window .history h5 {
@@ -301,34 +375,37 @@ div.occupants &gt; a.up { @@ -301,34 +375,37 @@ div.occupants &gt; a.up {
301 background: #585858; 375 background: #585858;
302 border: 1px solid #6B6B6B; 376 border: 1px solid #6B6B6B;
303 } 377 }
304 -#chat #user-status {  
305 - padding: 2px 4px;  
306 - float: left; 378 +#buddy-list #user-status {
  379 + display: table-cell;
  380 + vertical-align: middle;
  381 + padding: 0 5px;
  382 + white-space: nowrap;
  383 + transition: padding 0.3s ease-in;
  384 +}
  385 +#buddy-list:hover #user-status {
  386 + padding: 0 15px;
  387 + transition: padding 0.3s ease-in;
307 } 388 }
308 #chat .user-status a { 389 #chat .user-status a {
309 color: rgb(224, 224, 224); 390 color: rgb(224, 224, 224);
310 } 391 }
311 -#chat .user-status > a {  
312 - position: relative;  
313 - left: -15px;  
314 -}  
315 392
316 .user-status { 393 .user-status {
317 - vertical-align: bottom;  
318 - bottom: -5px; 394 + vertical-align: middle;
319 } 395 }
320 396
321 .user-status span { 397 .user-status span {
322 position: relative; 398 position: relative;
323 } 399 }
324 .user-status span, .user-status .ui-icon { 400 .user-status span, .user-status .ui-icon {
325 - top: -3px; 401 + margin-left: 7px;
326 } 402 }
327 403
328 .conversation .author { 404 .conversation .author {
329 - width: 20%; 405 + width: 32px;
330 display: inline-block; 406 display: inline-block;
331 vertical-align: top; 407 vertical-align: top;
  408 + float: left;
332 } 409 }
333 .conversation .self .author { 410 .conversation .self .author {
334 float: right; 411 float: right;