Module: MobileHelper

Defined in:
app/helpers/mobile_helper.rb

Instance Method Summary collapse

Instance Method Details

#additional_photosObject


63
64
65
66
67
# File 'app/helpers/mobile_helper.rb', line 63

def additional_photos
  if photo.status_message_guid?
    @additional_photos ||= photo.status_message.photos.order(:created_at)
  end
end

#mobile_comment_icon(post) ⇒ Object


42
43
44
45
46
# File 'app/helpers/mobile_helper.rb', line 42

def mobile_comment_icon(post)
  link_to (:span, post.comments.size, class: "count comment-count"),
          new_post_comment_path(post),
          class: "entypo-comment comment-action inactive"
end

#mobile_like_icon(post) ⇒ Object


28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/helpers/mobile_helper.rb', line 28

def mobile_like_icon(post)
  if current_user && current_user.liked?(post)
    link_to (:span, post.likes.size, class: "count like-count"),
            "#",
            data:  {url: post_like_path(post.id, current_user.like_for(post).id)},
            class: "entypo-heart like-action active"
  else
    link_to (:span, post.likes.size, class: "count like-count"),
            "#",
            data:  {url: post_likes_path(post.id)},
            class: "entypo-heart like-action inactive"
  end
end

#mobile_reshare_icon(post) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/helpers/mobile_helper.rb', line 4

def mobile_reshare_icon(post)
  if (post.public? || reshare?(post)) && (user_signed_in? && post.author != current_user.person)
    absolute_root = reshare?(post) ? post.absolute_root : post

    if absolute_root && absolute_root.author != current_user.person
      reshare = Reshare.where(author_id: current_user.person_id,
                              root_guid: absolute_root.guid).first
      klass = reshare.present? ? "active" : "inactive"
      link_to (:span, post.reshares.size, class: "count reshare-count"),
              reshares_path(root_guid: absolute_root.guid),
              title: t("reshares.reshare.reshare_confirmation", author: absolute_root.author_name),
              class: "entypo-reshare reshare-action #{klass}"
    else
       :div,
                  (:span, post.reshares.size, class: "count reshare-count"),
                  class: "entypo-reshare reshare-action disabled"
    end
  else
     :div,
                (:span, post.reshares.size, class: "count reshare-count"),
                class: "entypo-reshare reshare-action disabled"
  end
end

#next_photoObject


69
70
71
72
# File 'app/helpers/mobile_helper.rb', line 69

def next_photo
  @next_photo ||= additional_photos[additional_photos.index(photo)+1]
  @next_photo ||= additional_photos.first
end

#photoObject


78
79
80
# File 'app/helpers/mobile_helper.rb', line 78

def photo
  @photo ||= current_user.find_visible_shareable_by_id(Photo, params[:id])
end

#previous_photoObject


74
75
76
# File 'app/helpers/mobile_helper.rb', line 74

def previous_photo
  @previous_photo ||= additional_photos[additional_photos.index(photo)-1]
end

48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/helpers/mobile_helper.rb', line 48

def show_comments_link(post, klass="")
  if klass == "active"
    entypo_class = "entypo-chevron-up"
  else
    entypo_class = "entypo-chevron-down"
  end

  link_to safe_join([
                      t("admins.stats.comments", count: post.comments_count),
                      (:i, nil, class: entypo_class)
                    ]),
          post_comments_path(post, format: "mobile"),
          class: "show-comments #{klass}"
end