Skip to content
Extraits de code Groupes Projets
Valider d503c654 rédigé par Raphael's avatar Raphael
Parcourir les fichiers

RS; posted statuses now use the websocket to update latest, time is now styled right

parent b8ae6b44
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -22,6 +22,8 @@ module SocketsHelper
if object.is_a? Photo
action_hash[:photo_hash] = object.thumb_hash
elsif object.is_a? StatusMessage
action_hash[:status_message_hash] = object.latest_hash
end
action_hash.to_json
......
......@@ -21,9 +21,8 @@ class StatusMessage < Post
XML
end
def ==(other)
(self.message == other.message) && (self.person.email == other.person.email)
def latest_hash
{:mine? => self.person == User.owner, :text => message}
end
end
......@@ -20,9 +20,13 @@
}else if (obj['class']=='photos' && onPageForClass('albums')){
processPhotoInAlbum(obj['photo_hash'])
}else if (obj['class']=='status_messages'){
processStatusMessage(obj['class'], obj['html'], obj['status_message_hash'])
}else{
processPost(obj['class'], obj['html'])
}
};
ws.onclose = function() { debug("socket closed"); };
ws.onopen = function() {
......@@ -56,6 +60,18 @@
}
}
function processStatusMessage(className, html, messageHash){
processPost(className, html);
if(messageHash['mine?']){
updateMyLatestStatus(messageHash);
}
}
function updateMyLatestStatus(messageHash){
$("#latest_message").text(messageHash['text']);
$("#latest_message_time").text(' - just now');
}
function processPhotoInAlbum(photoHash){
if (location.href.indexOf(photoHash['album_id']) == -1){
return ;
......@@ -65,7 +81,7 @@
<img alt=\"New thumbnail\" src=\""+ photoHash['thumb_url'] +"\" /> \
</a> </div>"
$("#thumbnails").append( $(html) )
$(".image_thumb img").load( function() {
$("#"+ photoHash['id'] + " img").load( function() {
$(this).fadeIn("slow");
});
}
......
......@@ -50,9 +50,9 @@
= link_to current_user.real_name, root_path
%span#latest_message
= my_latest_message
- unless @latest_status_message.nil?
%span{:style => "font-size: small"}
= " - #{how_long_ago @latest_status_message}"
- unless @latest_status_message.nil?
%span{:style => "font-size: small", :id => 'latest_message_time'}
= " - #{how_long_ago @latest_status_message}"
%ul.nav
%li= link_to "home", root_path
......
......@@ -7,8 +7,6 @@
$("#new_status_message").submit(function() {
var new_status = $('#status_message_message').val() + " - just now";
$('#latest_message').text( new_status );
});
function selectPublisherTab(evt){
......
......@@ -177,6 +177,11 @@ form {
#user_name #latest_message span {
size: small;
font-style: italic; }
#user_name #latest_message_time{
font-weight: normal;
color: #999999;
size: small;
font-style: italic; }
#user_name ul {
display: inline;
margin: 0;
......
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