module ApplicationHelper
  def second_button(star)
    if current_user.can_second?(star)
      link_to "Second", star_seconds_url(star), :class => "second",
        'data-remote' => true, 'data-replace-id' => "star_#{star.id}",
        'data-method' => 'post'
    end
  end

  FRIENDLY_TIME_FORMAT = '%b %d at %I:%M%p'
  def friendly_time(time)
    time.getlocal.strftime(FRIENDLY_TIME_FORMAT).
         gsub(/(\s|^)0/, '\\1').
         sub('AM', 'am').
         sub('PM', 'pm')
  end

  def photo(user)
    image_url =
      "http://graph.facebook.com/#{user.facebook_uid.to_i}/picture?type=square"
    link_to image_tag(image_url, :class => "user_photo", :alt => ""),
      user_url(user)
  end

  def background_photo(user)
    image_url =
      "http://graph.facebook.com/#{user.facebook_uid.to_i}/picture?type=large"
    div = content_tag(:div, "", :class => "user_photo", :style =>
      "background-image: url('#{image_url}');
       background-position: center; background-size: cover")
    link_to div, user_path(user)
  end

  def stylesheet(path)
    @stylesheets << path
  end
end

module ApplicationHelper
  def second_button(star)
    if current_user.can_second?(star)
      link_to 'Second', star_seconds_url(star), :class => 'second',
        'data-remote' => true, 'data-replace-id' => "star_#{star.id}",
        'data-method' => 'post'
    end
  end

  FRIENDLY_TIME_FORMAT = '%b %d at %I:%M%p'
  def friendly_time(time)
    time.getlocal.strftime(FRIENDLY_TIME_FORMAT).
         gsub(/(\s|^)0/, '\\1').
         sub('AM', 'am').
         sub('PM', 'pm')
  end

  def photo(user)
    image_url =
      "http://graph.facebook.com/#{user.facebook_uid.to_i}/picture?type=square"
    link_to image_tag(image_url, :class => 'user_photo', :alt => '',
                      :title => user.name)
      user_url(user)
  end

  def background_photo(user)
    image_url =
      "http://graph.facebook.com/#{user.facebook_uid.to_i}/picture?type=large"
    div = content_tag(:div, '', :class => 'user_photo', :title => user.name,
                      :style => "background-image: url('#{image_url}');" +
                        'background-position: center; background-size: cover')
    link_to div, user_path(user)
  end

  def stylesheet(path)
    @stylesheets << path
  end
end

Add names to user photos
Add names to user photos

When using Stars, it can be difficult to know who a particular user
photo belongs to. This commit adds names to user photos via title
attributes, which should appear as tooltips when hovering.

Change-Id: I938239a3644c4a99b3eeb38109accc3ca8fe3246
Reviewed-on: https://gerrit.causes.com/11921
Reviewed-by: Kim Douglas Clarence Mason <b21f0a9a26d2288a382e1db897c9c0db98688f4c@causes.com>
Reviewed-by: Greg Hurrell <79e2475f81a6317276bf7cbb3958b20d289b78df@causes.com>
Tested-by: Kim Douglas Clarence Mason <b21f0a9a26d2288a382e1db897c9c0db98688f4c@causes.com>
