Sha256: 8244532365f82f020e03b78699a4161f55a41fe2b0d46588991705d19256b7d0

Contents?: true

Size: 1.76 KB

Versions: 31

Compression:

Stored size: 1.76 KB

Contents

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

$(() => {
  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

31 entries across 31 versions & 1 rubygems

Version Path
decidim-consultations-0.27.9 app/packs/src/decidim/consultations/vote_dialog.js
decidim-consultations-0.27.8 app/packs/src/decidim/consultations/vote_dialog.js
decidim-consultations-0.27.7 app/packs/src/decidim/consultations/vote_dialog.js
decidim-consultations-0.27.6 app/packs/src/decidim/consultations/vote_dialog.js
decidim-consultations-0.26.10 app/packs/src/decidim/consultations/vote_dialog.js
decidim-consultations-0.26.9 app/packs/src/decidim/consultations/vote_dialog.js
decidim-consultations-0.27.5 app/packs/src/decidim/consultations/vote_dialog.js
decidim-consultations-0.26.8 app/packs/src/decidim/consultations/vote_dialog.js
decidim-consultations-0.27.4 app/packs/src/decidim/consultations/vote_dialog.js
decidim-consultations-0.27.3 app/packs/src/decidim/consultations/vote_dialog.js
decidim-consultations-0.26.7 app/packs/src/decidim/consultations/vote_dialog.js
decidim-consultations-0.26.5 app/packs/src/decidim/consultations/vote_dialog.js
decidim-consultations-0.27.2 app/packs/src/decidim/consultations/vote_dialog.js
decidim-consultations-0.27.1 app/packs/src/decidim/consultations/vote_dialog.js
decidim-consultations-0.26.4 app/packs/src/decidim/consultations/vote_dialog.js
decidim-consultations-0.27.0 app/packs/src/decidim/consultations/vote_dialog.js
decidim-consultations-0.26.3 app/packs/src/decidim/consultations/vote_dialog.js
decidim-consultations-0.27.0.rc2 app/packs/src/decidim/consultations/vote_dialog.js
decidim-consultations-0.27.0.rc1 app/packs/src/decidim/consultations/vote_dialog.js
decidim-consultations-0.26.2 app/packs/src/decidim/consultations/vote_dialog.js