.awards.votes-block
  - awards_sort(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
          = text_field_tag :emoji_search, "", class: "emoji-search search-input form-control"
          - AwardEmoji.emoji_by_category.each do |category, emojis|
            %h5= AwardEmoji::CATEGORIES[category]
            %ul
              - emojis.each do |emoji|
                %li
                  = emoji_icon(emoji["name"], emoji["unicode"], emoji["aliases"])

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

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

    $(".awards").on("click", ".emoji-menu-content li", function(e) {
      var emoji = $(this).find(".emoji-icon").data("emoji");
      awards_handler.addAward(emoji);
    });

    $(".awards").on("click", ".award", function(e) {
      var emoji = $(this).find(".icon").data("emoji");
      awards_handler.addAward(emoji);
    });

    $(".award").tooltip();

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