Skip to content
Extraits de code Groupes Projets
Valider 5fa2a7a6 rédigé par danielgrippi's avatar danielgrippi
Parcourir les fichiers

use popState in message inbox

parent 72d8b4a7
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
class ConversationsController < ApplicationController class ConversationsController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
respond_to :html, :json respond_to :html, :json, :js
def index def index
@conversations = Conversation.joins(:conversation_visibilities).where( @conversations = Conversation.joins(:conversation_visibilities).where(
...@@ -44,17 +44,12 @@ class ConversationsController < ApplicationController ...@@ -44,17 +44,12 @@ class ConversationsController < ApplicationController
def show def show
@conversation = Conversation.joins(:conversation_visibilities).where(:id => params[:id], @conversation = Conversation.joins(:conversation_visibilities).where(:id => params[:id],
:conversation_visibilities => {:person_id => current_user.person.id}).first :conversation_visibilities => {:person_id => current_user.person.id}).first
if @visibility = ConversationVisibility.where(:conversation_id => params[:id], :person_id => current_user.person.id).first if @visibility = ConversationVisibility.where(:conversation_id => params[:id], :person_id => current_user.person.id).first
@visibility.unread = 0 @visibility.unread = 0
@visibility.save @visibility.save
end end
if @conversation respond_with @conversation
render :layout => false
else
redirect_to conversations_path
end
end end
def new def new
......
...@@ -2,20 +2,21 @@ ...@@ -2,20 +2,21 @@
-# licensed under the Affero General Public License version 3 or later. See -# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file. -# the COPYRIGHT file.
.stream_element.conversation{:data=>{:guid=>conversation.id}, :class => ('unread' if unread_counts[conversation.id].to_i > 0)} %a.conversation{:href => conversations_path(:conversation_id => conversation.id)}
= person_image_tag(authors[conversation.id]) .stream_element.conversation{:data=>{:guid=>conversation.id}, :class => ('unread' if unread_counts[conversation.id].to_i > 0)}
= person_image_tag(conversation.author)
.subject .subject
.message_count .message_count
= conversation.messages.size = conversation.messages.size
= conversation.subject[0..30] = conversation.subject[0..30]
.last_author .last_author
.timestamp .timestamp
= time_ago_in_words(conversation.updated_at) = time_ago_in_words(conversation.updated_at)
= authors[conversation.id].name = authors[conversation.id].name
- if conversation.participants.size > 2 - if conversation.participants.size > 2
%span.participant_count %span.participant_count
= "(+#{conversation.participants.size - 1})" = "(+#{conversation.participants.size - 1})"
$('#conversation_show').html("<%= escape_javascript(render('conversations/show', :conversation => @conversation)) %>");
$(".stream_element", "#conversation_inbox").removeClass('selected');
$(".stream_element[data-guid='<%= @conversation.id %>']", "#conversation_inbox").addClass('selected');
Diaspora.widgets.timeago.updateTimeAgo();
...@@ -5,24 +5,15 @@ ...@@ -5,24 +5,15 @@
$(document).ready(function(){ $(document).ready(function(){
var bindIt = function(element){ $('a.conversation').live('click', function(){
var conversationSummary = element, $.getScript(this.href);
conversationGuid = conversationSummary.attr('data-guid'); history.pushState(null, "", this.href);
$.get("conversations/"+conversationGuid, function(data){ return false;
});
$('.conversation', '.stream').removeClass('selected');
conversationSummary.addClass('selected').removeClass('unread');
$('#conversation_show').html(data);
Diaspora.widgets.timeago.updateTimeAgo();
});
if (typeof(history.pushState) == 'function') {
history.pushState(null, document.title, '?conversation_id='+conversationGuid);
}
}
$('.conversation', '.stream').bind('mousedown', function(){ $(window).bind("popstate", function(){
bindIt($(this)); $.getScript(location.href);
return false;
}); });
resize(); resize();
......
...@@ -320,6 +320,11 @@ header ...@@ -320,6 +320,11 @@ header
:margin 0 :margin 0
:padding 0 :padding 0
#conversation_inbox a
&:hover
:text
:decoration none
.stream_element .stream_element
:position relative :position relative
:word-wrap break-word :word-wrap break-word
...@@ -2621,7 +2626,12 @@ div.dislikes ...@@ -2621,7 +2626,12 @@ div.dislikes
&:hover:not(.selected) &:hover:not(.selected)
:background :background
:color #f0f0f0 :color #fafafa
&.selected:hover
:background
:color lighten($blue,5%)
&:hover &:hover
:cursor pointer :cursor pointer
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter