From fd015129c4c0184355f917fb0e0b31a8557ec295 Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Wed, 6 Jul 2011 13:41:42 -0700 Subject: [PATCH] final touchups to hovercard --- app/models/person.rb | 3 +- app/views/comments/_comment.html.haml | 2 +- app/views/layouts/_header.html.haml | 17 +++++------ app/views/people/_index.html.haml | 8 ++---- app/views/shared/_stream_element.html.haml | 2 +- config/assets.yml | 1 + public/javascripts/widgets/hovercard.js | 26 +++++++++++------ public/stylesheets/sass/application.sass | 33 +++++++++++++++------- 8 files changed, 57 insertions(+), 35 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index ec2c525f6..c56adb374 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -225,7 +225,8 @@ class Person < ActiveRecord::Base :name => self.name, :avatar => self.profile.image_url(:thumb_small), :handle => self.diaspora_handle, - :url => "/people/#{self.id}" + :url => "/people/#{self.id}", + :hashtags => self.profile.tags.map{|t| "##{t.name}"} } end diff --git a/app/views/comments/_comment.html.haml b/app/views/comments/_comment.html.haml index 35d07f4ac..0809a407b 100644 --- a/app/views/comments/_comment.html.haml +++ b/app/views/comments/_comment.html.haml @@ -9,7 +9,7 @@ = person_image_link(comment.author) .content %span.from - = person_link(comment.author, :class => "author") + = person_link(comment.author, :class => "hovercardable") %span{:class => direction_for(comment.text)} = markdownify(comment.text, :youtube_maps => comment.youtube_titles) diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 359b02e60..f5c0d084d 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -52,15 +52,16 @@ .ajax_loader = image_tag("ajax-loader.gif") - #hovercard - %img.avatar - %h4 - %a.person - #hovercard_dropdown_container + #hovercard_container + #hovercard + %img.avatar + %h4 + %a.person + #hovercard_dropdown_container - .hovercard_footer - .footer_container - Message + .hovercard_footer + .footer_container + .hashtags %ul#user_menu.dropdown %li diff --git a/app/views/people/_index.html.haml b/app/views/people/_index.html.haml index d7f36f7af..72df7e017 100644 --- a/app/views/people/_index.html.haml +++ b/app/views/people/_index.html.haml @@ -5,13 +5,9 @@ - if current_user - contact = current_user.contacts.find_by_person_id(person.id) - contact ||= Contact.new(:person => person) - - unless person == current_user.person - .right - = render 'aspect_memberships/aspect_dropdown', :contact => contact, :person => person, :hang => 'left' .content %span.from - =person_link(person) - .info - = person.profile.format_tags(person.profile.tag_string) + =person_link(person, :class => "hovercardable") + = will_paginate people, :params => {:controller => 'people', :action => 'tag_index'} diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml index e65d3e039..bc075a6c9 100644 --- a/app/views/shared/_stream_element.html.haml +++ b/app/views/shared/_stream_element.html.haml @@ -18,7 +18,7 @@ .content %div.post_initial_info %span.from - = person_link(post.author, :class => 'author') + = person_link(post.author, :class => 'hovercardable') %time.time.timeago{:datetime => post.created_at, :integer => time_for_sort(post).to_i} %span.details \- diff --git a/config/assets.yml b/config/assets.yml index bf4808b75..a3a2b3037 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -36,6 +36,7 @@ javascripts: - public/javascripts/widgets/flashes.js - public/javascripts/widgets/post.js - public/javascripts/widgets/hovercard.js + - public/javascripts/widgets/notifications-badge.js - public/javascripts/view.js - public/javascripts/stream.js - public/javascripts/content-updater.js diff --git a/public/javascripts/widgets/hovercard.js b/public/javascripts/widgets/hovercard.js index 5ed15ed77..ab171a275 100644 --- a/public/javascripts/widgets/hovercard.js +++ b/public/javascripts/widgets/hovercard.js @@ -7,20 +7,22 @@ this.start = function() { self.personCache = new this.Cache(); self.dropdownCache = new this.Cache(); - + + var card = $("#hovercard"); self.hoverCard = { - tip: $("#hovercard"), + tip: $("#hovercard_container"), dropdownContainer: $("#hovercard_dropdown_container"), offset: { - left: 0, - top: 18 + left: -10, + top: 13 }, - personLink: $("#hovercard").find("a.person"), - avatar: $("#hovercard").find(".avatar"), - dropdown: $("#hovercard").find(".dropdown_list") + personLink: card.find("a.person"), + avatar: card.find(".avatar"), + dropdown: card.find(".dropdown_list"), + hashtags: card.find(".hashtags"), }; - $(document.body).delegate("a.author:not(.self)", "hover", self.handleHoverEvent); + $(document.body).delegate("a.hovercardable:not(.self)", "hover", self.handleHoverEvent); self.hoverCard.tip.hover(self.hoverCardHover, self.clearTimeout); Diaspora.widgets.subscribe("aspectDropdown/updated aspectDropdown/blurred", function(evt, personId, dropdownHtml) { @@ -67,6 +69,14 @@ self.hoverCard.personLink.text(person.name); self.hoverCard.dropdown.attr("data-person-id", person.id); + $.each(person.hashtags, function(index, hashtag) { + self.hoverCard.hashtags.append( + $("", { + href: "/tags/" + hashtag.substring(1) + }).text(hashtag) + ); + }); + self.dropdownCache.get(self.target.attr("href") + "/aspect_membership_button", function(dropdown) { self.hoverCard.dropdownContainer.html(dropdown); self.hoverCard.tip.fadeIn(140); diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index beb82a38f..db819df67 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -3066,14 +3066,12 @@ ul.left_nav :margin :top 30px -.tags_people - .dropdown - :display none - #hovercard @include border-radius(2px) @include box-shadow(0,0,5px,#666) + :position relative + .avatar :position relative :height 70px @@ -3081,21 +3079,16 @@ ul.left_nav :margin :right 10px - :position absolute - :display none :background :color $background :padding 5px - :bottom 28px + :bottom 55px :border 1px solid #999 :width 220px - :z - :index 10 - .hovercard_footer :position absolute :bottom 0 @@ -3104,6 +3097,9 @@ ul.left_nav :color #eee :width 100% + :height 20px + :min-height 20px + :font :size smaller @@ -3112,3 +3108,20 @@ ul.left_nav .footer_container :padding 2px 5px + + .hashtags + :overflow hidden + :white-space nowrap + :text-overflow ellipsis + + a + :color #999 + :margin + :right 4px + +#hovercard_container + :padding 10px + :top 5px + :position absolute + :display none + :z-index 10