Module: LoyalCore::Ajax::LikeTracksHelper

Included in:
LoyalCore::ActionHelper
Defined in:
lib/loyal_core/action_helper/ajax/like_tracks_helper.rb

Instance Method Summary collapse

Instance Method Details



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/loyal_core/action_helper/ajax/like_tracks_helper.rb', line 5

def loyal_core_helper_ajax_liker_link_to target, options={}
  link_to  "javascript:;", {
    'march-on' => 'ajax',
    'march-type' => 'march-type',
    'march-id' => target.uuid,
    'march-action' => 'like'
  }.merge(options) do
    html = ""
    html << (
      image_tag image_path("loyal_core/liked.gif"), :class => 'liked', :style => "display: #{target.liked_by?(current_user) ? 'inline' : 'none'};"
    )

    html << (
      image_tag image_path("loyal_core/unlike.gif"), :class => 'unlike', :style => "display: #{target.liked_by?(current_user) ? 'none' : 'inline'};"
    )
    html << "<span class='count'>#{target.liked_count}</span>"
    raw html
  end
end