(function () { 'use strict'; $('#question-vote-modal').foundation("close"); $('#question-vote-confirm-modal').foundation("close"); $('#question-vote-modal, #question-vote-confirm-modal').remove() var voteButton = $('#question-<%= current_question.id %>-vote-button'); voteButton.html('<%= j(render partial: "decidim/consultations/questions/vote_button", locals: { question: current_question }) %>'); $('#question-vote-modal').foundation(); $('#question-vote-confirm-modal').foundation(); <% if signed_in? && current_question.voted_by?(current_user) %> $('#vote-result-callout').addClass('warning').removeClass('hide danger'); $('#vote-result-callout .callout-title').text($('#vote-result-callout').data('title-ok')); $('#vote-result-callout .callout-message').text($('#vote-result-callout').data('message-ok')); $('#confirm-vote-form-loader').addClass('hide'); $('#confirm-vote-form').removeClass('hide'); <% end %> // Replicate the behaviour of vote_dialog.js as it has a bug when changed via ajax var button = $("#vote_button"), buttonChange = $("#question-vote-confirm-modal-button-change"), responseButtons = $(".response-title"), voteConfirmDialog = $("#question-vote-confirm-modal"), voteDialog = $("#question-vote-modal"); if (voteDialog.length && button.length) { button.click(function () { voteDialog.foundation("open"); }); } if (voteDialog.length && responseButtons.length && voteConfirmDialog.length) { responseButtons.click(function () { $("#question-vote-confirm-modal-question-title").text($(this).text()); $("#decidim_consultations_response_id").val($(this).data("response-id")); voteDialog.foundation("close"); voteConfirmDialog.foundation("open"); }); } if (buttonChange.length && voteDialog.length && voteConfirmDialog.length) { buttonChange.click(function() { voteConfirmDialog.foundation("close"); voteDialog.foundation("open"); }); } //lets do the same for delegations var delegationsButton = $("#delegations-button"), delegationCallouts = $(".delegation-callout"), delegationCalloutsMessage = $(".delegation-callout-message"), delegationVoteButtons = $(".delegation-vote-button"), delegationUnVoteButtons = $(".delegation_unvote_button"), delegationField = $("#decidim_consultations_delegation_id"), delegationDialog = $("#delegations-modal"); delegationDialog.foundation(); delegationsButton.click(function () { delegationDialog.foundation("open"); }); delegationVoteButtons.click((evt) => { delegationDialog.foundation("close"); voteDialog.foundation("open"); delegationField.val($(evt.currentTarget).data("delegation-id")); delegationCalloutsMessage.text($(evt.currentTarget).data("delegation-granter-name")); delegationCallouts.removeClass("is-hidden"); }); delegationUnVoteButtons.click((evt) => { delegationDialog.foundation("close"); delegationCallouts.addClass("is-hidden"); }); button.click(() => { delegationCallouts.addClass("is-hidden"); }); }());