<% @paragraphs.each do |paragraph| %> (function() { var $paragraphVotesCount = $('#paragraph-<%= paragraph.id %>-votes-count'); if($paragraphVotesCount[0]) { morphdom($paragraphVotesCount[0], '<%= j(render partial: "decidim/enhanced_textwork/paragraphs/votes_count", locals: { paragraph: paragraph, from_paragraphs_list: @from_paragraphs_list }).strip.html_safe %>'); } var $paragraphVoteButton = $('#paragraph-<%= paragraph.id %>-vote-button'); if($paragraphVoteButton[0]) { morphdom($paragraphVoteButton[0], '<%= j(render partial: "decidim/enhanced_textwork/paragraphs/vote_button", locals: { paragraph: paragraph, from_paragraphs_list: @from_paragraphs_list, chevron_button: @chevron_button }).strip.html_safe %>'); } })(); <% end %> <% if vote_limit_enabled? %> (function() { var $remainingVotesCount = $('#remaining-votes-count'); var $notVotedButtons = $('.card__button.button').not('.success'); if(!$remainingVotesCount[0]) { return; } morphdom($remainingVotesCount[0], '<%= j(render partial: "decidim/enhanced_textwork/paragraphs/remaining_votes_count").strip.html_safe %>'); <% if remaining_votes_count_for(current_user) == 0 %> $notVotedButtons.attr('disabled', true); $notVotedButtons.val('<%= t("decidim.enhanced_textwork.paragraphs.vote_button.no_votes_remaining") %>'); <% else %> $notVotedButtons.attr('disabled', false); $notVotedButtons.val('<%= t("decidim.enhanced_textwork.paragraphs.vote_button.vote") %>'); <% end %> }()); <% end %> <% if show_voting_rules? %> (function() { var $votingRules = $('.voting-rules'); if(!$votingRules[0]) { return; } morphdom($votingRules[0], '<%= j(render partial: "decidim/enhanced_textwork/paragraphs/voting_rules").strip.html_safe %>'); }()); <% end %>