if ($("#itemFeedback").data("show-reasons")) $("#itemFeedback-explanation").hide() else $("#itemFeedback-reason").hide() $("#itemFeedback-question__yes").on("click", () => { const $container = $("#itemFeedback") const data = { id: $container.data("id"), type: $container.attr("id"), url: window.location.href, yesOrNo: 'yes' }; $.ajax({ type: "POST", url: "/rest/pollfeedback/", data, error: console.log }); if ($container.data("has-no-thanks")) { $("#itemFeedback-header").css("border-bottom", "none"); $("#itemFeedback-body").css("padding", "0"); } $("#itemFeedback-heading").text("Vielen Dank für Ihr Feedback!") $("#itemFeedback-question").hide() $("#itemFeedback-thanks").show() }) $("#itemFeedback-question__no").on("click", () => { const $container = $("#itemFeedback") const data = { id: $container.data("id"), type: $container.attr("id"), url: window.location.href, yesOrNo: 'no' }; $.ajax({ type: "POST", url: "/rest/pollfeedback/", data, error: console.log }); }) $("#itemFeedback-close").on("click", () => { $("#itemFeedback-question").hide() $("#itemFeedback-thanks").show() }) $(".itemFeedback-reason__btn").on("click", (e) => { const $container = $("#itemFeedback") const $pressedButton = $(e.target) const reason = $pressedButton.data("reason") const data = { id: $container.data("id"), reason }; $.ajax({ type: "POST", url: "/rest/pollfeedback-reason/", data, error: console.log }); $("#itemFeedback-form__reason").text($pressedButton.text()) $("#itemFeedback-reason").hide() $("#itemFeedback-explanation").show() }) $("#itemFeedback-form").on("submit", (e) => { e.preventDefault() const $container = $("#itemFeedback") const explanation = $("#itemFeedback-form__feedback").val() const data = { id: $container.data("id"), explanation }; $.ajax({ type: "POST", url: "/rest/pollfeedback-explanation/", data, error: console.log }); if ($container.data("has-no-thanks")) { $("#itemFeedback-header").css("border-bottom", "none"); $("#itemFeedback-body").css("padding", "0"); } $("#itemFeedback-heading").text("Vielen Dank für Ihr Feedback!") $("#itemFeedback-question").hide() $("#itemFeedback-thanks").show() $("#itemFeedback-close").click() })