summaryrefslogtreecommitdiff
path: root/app/views/votes/_votes_block.html.haml
blob: 8c660ba16cc67618d1e0e59c80b71cafbbff090c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
.awards.votes-block
  - votable.notes.awards.grouped_awards.each do |emoji, notes|
    .award{class: (note_active_class(notes, current_user)), title: emoji_author_list(notes, current_user)}
      = emoji_icon(emoji)
      .counter
        = notes.count

  - if current_user
    .awards-controls
      %a.add-award{"data-toggle" => "dropdown", "data-target" => "#", "href" => "#"}
        = icon('smile-o')
      .emoji-menu
        .emoji-menu-content
          - AwardEmoji.emoji_by_category.each do |category, emojis|
            %h5= AwardEmoji::CATEGORIES[category]
            %ul
              - emojis.each do |emoji|
                %li
                  = emoji_icon(emoji["name"], emoji["unicode"])

- if current_user
  :coffeescript
    post_emoji_url = "#{award_toggle_namespace_project_notes_path(@project.namespace, @project)}"
    noteable_type = "#{votable.class.name.underscore}"
    noteable_id = "#{votable.id}"
    aliases = #{AwardEmoji::ALIASES.to_json}

    window.awards_handler = new AwardsHandler(
      post_emoji_url,
      noteable_type,
      noteable_id,
      aliases
    )

    $(".emoji-menu-content li").click (e)->
      emoji = $(this).find(".emoji-icon").data("emoji")
      awards_handler.addAward(emoji)

    $(".awards").on "click", ".award", (e)->
      emoji = $(this).find(".icon").data("emoji")
      awards_handler.addAward(emoji)

    $(".award").tooltip()

    $(".emoji-menu-content").niceScroll({cursorwidth: "7px", autohidemode: false})