BigW Consortium Gitlab

_votes_block.html.haml 1.2 KB
.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{"href" => "#"}
        = icon('smile-o')

- 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});