use popState in message inbox
This commit is contained in:
parent
72d8b4a7e6
commit
5fa2a7a6f3
5 changed files with 41 additions and 38 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
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
|
||||||
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 @@
|
||||||
-# 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})"
|
||||||
|
|
|
||||||
6
app/views/conversations/index.js.erb
Normal file
6
app/views/conversations/index.js.erb
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
$('#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 @@
|
||||||
|
|
||||||
$(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');
|
$(window).bind("popstate", function(){
|
||||||
conversationSummary.addClass('selected').removeClass('unread');
|
$.getScript(location.href);
|
||||||
$('#conversation_show').html(data);
|
return false;
|
||||||
Diaspora.widgets.timeago.updateTimeAgo();
|
|
||||||
});
|
|
||||||
|
|
||||||
if (typeof(history.pushState) == 'function') {
|
|
||||||
history.pushState(null, document.title, '?conversation_id='+conversationGuid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$('.conversation', '.stream').bind('mousedown', function(){
|
|
||||||
bindIt($(this));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
resize();
|
resize();
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
&: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
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue