Sha256: 112b849ad6520900628504609388ef374d70d88d1296be8c3c9c4a758b78053a

Contents?: true

Size: 1.78 KB

Versions: 20

Compression:

Stored size: 1.78 KB

Contents

/* eslint-disable no-invalid-this */

$(document).ready(function () {
  let 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");
    });
  }

  $("#confirm-vote-form").on("ajax:beforeSend", function() {
    $("#confirm-vote-form-loader,#confirm-vote-form").toggleClass("hide");
  });

  $("#confirm-vote-form").on("ajax:success", function() {
    voteConfirmDialog.foundation("close");
  });

  $("#confirm-vote-form").on("ajax:error", function(event) {
    const error = event && event.detail && event.detail[0].error;
    $("#vote-result-callout").addClass("alert").removeClass("hide warning");
    $("#vote-result-callout .callout-title").text($("#vote-result-callout").data("title-ko"));
    $("#vote-result-callout .callout-message").text(error || $("#vote-result-callout").data("message-ko"));
    $("#confirm-vote-form-loader,#confirm-vote-form").toggleClass("hide");
    voteConfirmDialog.foundation("close");
  });
});

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
decidim-consultations-0.24.3 app/assets/javascripts/decidim/consultations/vote_dialog.js
decidim-consultations-0.23.6 app/assets/javascripts/decidim/consultations/vote_dialog.js
decidim-consultations-0.24.2 app/assets/javascripts/decidim/consultations/vote_dialog.js
decidim-consultations-0.23.5 app/assets/javascripts/decidim/consultations/vote_dialog.js
decidim-consultations-0.24.1 app/assets/javascripts/decidim/consultations/vote_dialog.js
decidim-consultations-0.24.0 app/assets/javascripts/decidim/consultations/vote_dialog.js
decidim-consultations-0.24.0.rc2 app/assets/javascripts/decidim/consultations/vote_dialog.js
decidim-consultations-0.23.4 app/assets/javascripts/decidim/consultations/vote_dialog.js
decidim-consultations-0.24.0.rc1 app/assets/javascripts/decidim/consultations/vote_dialog.js
decidim-consultations-0.23.3 app/assets/javascripts/decidim/consultations/vote_dialog.js
decidim-consultations-0.23.2 app/assets/javascripts/decidim/consultations/vote_dialog.js
decidim-consultations-0.23.1 app/assets/javascripts/decidim/consultations/vote_dialog.js
decidim-consultations-0.23.1.rc1 app/assets/javascripts/decidim/consultations/vote_dialog.js
decidim-consultations-0.23.0 app/assets/javascripts/decidim/consultations/vote_dialog.js
decidim-consultations-0.22.0 app/assets/javascripts/decidim/consultations/vote_dialog.js
decidim-consultations-0.21.0 app/assets/javascripts/decidim/consultations/vote_dialog.js
decidim-consultations-0.20.1 app/assets/javascripts/decidim/consultations/vote_dialog.js
decidim-consultations-0.20.0 app/assets/javascripts/decidim/consultations/vote_dialog.js
decidim-consultations-0.19.1 app/assets/javascripts/decidim/consultations/vote_dialog.js
decidim-consultations-0.19.0 app/assets/javascripts/decidim/consultations/vote_dialog.js