summaryrefslogtreecommitdiff
path: root/app/views/votes/_votes_block.html.haml
blob: 04e3b5a3814a20485a28694e7b06c11d3ce8c594 (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
.awards.votes-block
  - votable.notes.awards.grouped_awards.each do | note |
    .award{class: (note_active_class(note.last, current_user)), title: emoji_author_list(note.last, current_user)}
      .icon{"data-emoji" => "#{note.first}"}
        = image_tag url_to_emoji(note.first), height: "20px", width: "20px"
      .counter
        = note.last.count

  - if current_user
    .dropdown.awards-controls
      %a.add-award{"data-toggle" => "dropdown", "data-target" => "#", "href" => "#"}
        = icon('plus-square-o')
      %ul.dropdown-menu.awards-menu
        - emoji_list.each do |emoji|
          %li{"data-emoji" => "#{emoji}"}= image_tag url_to_emoji(emoji), height: "20px", width: "20px"

- if current_user
  :coffeescript
    post_emoji_url = "#{award_toggle_namespace_project_notes_path(@project.namespace, @project)}"
    noteable_type = "#{votable.class}"
    noteable_id = "#{votable.id}"
    window.awards_handler = new AwardsHandler(post_emoji_url, noteable_type, noteable_id)

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

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

    $(".award").tooltip()