diff --git a/app/controllers/conversations_controller.rb b/app/controllers/conversations_controller.rb index d652ec74dde5636e4754b3a4dbed0958db4c75ed..cd0a01202b041d2b7d7cdb188edd27f69501040b 100644 --- a/app/controllers/conversations_controller.rb +++ b/app/controllers/conversations_controller.rb @@ -1,7 +1,7 @@ class ConversationsController < ApplicationController before_filter :authenticate_user! - respond_to :html, :json + respond_to :html, :json, :js def index @conversations = Conversation.joins(:conversation_visibilities).where( @@ -44,17 +44,12 @@ class ConversationsController < ApplicationController def show @conversation = Conversation.joins(:conversation_visibilities).where(:id => params[:id], :conversation_visibilities => {: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.save end - if @conversation - render :layout => false - else - redirect_to conversations_path - end + respond_with @conversation end def new diff --git a/app/views/conversations/_conversation.haml b/app/views/conversations/_conversation.haml index 35657566eaac90760cfab2ef2c62cb3d9587c68d..2083a53b70c581873634943945e94265c1a0ca48 100644 --- a/app/views/conversations/_conversation.haml +++ b/app/views/conversations/_conversation.haml @@ -2,20 +2,21 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. -.stream_element.conversation{:data=>{:guid=>conversation.id}, :class => ('unread' if unread_counts[conversation.id].to_i > 0)} - = person_image_tag(authors[conversation.id]) +%a.conversation{:href => conversations_path(:conversation_id => 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 - .message_count - = conversation.messages.size + .subject + .message_count + = conversation.messages.size - = conversation.subject[0..30] + = conversation.subject[0..30] - .last_author - .timestamp - = time_ago_in_words(conversation.updated_at) - = authors[conversation.id].name + .last_author + .timestamp + = time_ago_in_words(conversation.updated_at) + = authors[conversation.id].name - - if conversation.participants.size > 2 - %span.participant_count - = "(+#{conversation.participants.size - 1})" + - if conversation.participants.size > 2 + %span.participant_count + = "(+#{conversation.participants.size - 1})" diff --git a/app/views/conversations/index.js.erb b/app/views/conversations/index.js.erb new file mode 100644 index 0000000000000000000000000000000000000000..36df45da9af47bebf57dd53d7fca0ff24f72b11d --- /dev/null +++ b/app/views/conversations/index.js.erb @@ -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(); diff --git a/public/javascripts/inbox.js b/public/javascripts/inbox.js index 1172b61c7f79384ac21e7ad88aaa5512790e31c8..00435e90dd40fea16c952478999984b5f028578f 100644 --- a/public/javascripts/inbox.js +++ b/public/javascripts/inbox.js @@ -5,24 +5,15 @@ $(document).ready(function(){ - var bindIt = function(element){ - var conversationSummary = element, - conversationGuid = conversationSummary.attr('data-guid'); - $.get("conversations/"+conversationGuid, function(data){ - - $('.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); - } - } + $('a.conversation').live('click', function(){ + $.getScript(this.href); + history.pushState(null, "", this.href); + return false; + }); - $('.conversation', '.stream').bind('mousedown', function(){ - bindIt($(this)); + $(window).bind("popstate", function(){ + $.getScript(location.href); + return false; }); resize(); diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index b314c8d68d92647e7d8e1e3a719b9e7f7756a254..8acc42da53dbe64c927c296f2fad6dc93b52b6b9 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -320,6 +320,11 @@ header :margin 0 :padding 0 +#conversation_inbox a + &:hover + :text + :decoration none + .stream_element :position relative :word-wrap break-word @@ -2621,7 +2626,12 @@ div.dislikes &:hover:not(.selected) :background - :color #f0f0f0 + :color #fafafa + + &.selected:hover + :background + :color lighten($blue,5%) + &:hover :cursor pointer