Sha256: ce3f719f3b5beadfefa5930a640ff1fa40bf01076626ee0f7c091277a63b26b8

Contents?: true

Size: 1017 Bytes

Versions: 2

Compression:

Stored size: 1017 Bytes

Contents

$(document).ready(function() {

  neutral = $("div.neutral").find("<%= by_url %>").parent();

  neutral.find("span#positive").html("<%= voting.positive.nonzero? %>");
  neutral.find("span#negative").html("<%= voting.negative.nonzero? %>");
  neutral.find("span#difference").html("<%= voting.difference.nonzero?.try(:abs) %>");

  neutral.find("span#difference").attr("class", "<%= voting.difference > 0 ? 'positive' : 'negative' %>");

  <% if vote.voter_id && Neutral.config.can_change %>

  neutral.find("a[class!='remove']").data('method', 'patch');
  neutral.find("a[class!='remove']").attr('data-method', 'patch');
  neutral.find("a.positive").attr('href', '<%= vote_path(1) %>');
  neutral.find("a.negative").attr('href', '<%= vote_path(0) %>');

  neutral.append('<%= escape_javascript(
    Neutral::VotingBuilder::Elements::Link::Remove.new(
      Neutral::VotingBuilder::Router.new(vote)[:remove],
      Neutral.icons.send(Neutral.config.default_icon_set).send(:remove)).to_s
    )
  %>');

  <% end %>

});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
neutral-0.0.2 app/views/neutral/votes/create.js.erb
neutral-0.0.1 app/views/neutral/votes/create.js.erb