Skip to content

Commit

Permalink
fix no-ajax + confirm
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala committed Nov 14, 2024
1 parent 7ea6559 commit 358b069
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
18 changes: 10 additions & 8 deletions javascript/cms-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
if (!input.length) {
// Add an input that track active tab
input = $(
'<input type="hidden" name="_activetab" class="no-change-track" id="js-form-active-tab" />'
'<input type="hidden" name="_activetab" class="no-change-track" id="js-form-active-tab" />',
);
$("#Form_ItemEditForm").append(input);
}
Expand All @@ -69,6 +69,13 @@
onmatch: function () {},
onunmatch: function () {},
onclick: function (e) {
if (this.hasClass("confirm")) {
var confirmed = confirm($(this).data("message"));
if (!confirmed) {
return;
}
}

if (this.attr("target") == "_blank") {
// Maybe not necessary?
e.stopPropagation();
Expand Down Expand Up @@ -162,9 +169,7 @@
}
// Update UI
if (data.progress_step && data.progress_total) {
var perc = Math.round(
(data.progress_step / data.progress_total) * 100
);
var perc = Math.round((data.progress_step / data.progress_total) * 100);
inst.find("span").text(perc + "%");
inst.find(".btn__progress").css("width", perc);
}
Expand Down Expand Up @@ -210,10 +215,7 @@
formData["progress_step"] = 0;

// Total can be preset
if (
typeof this.data("progress-total") !== "undefined" &&
this.data("progress-total") !== null
) {
if (typeof this.data("progress-total") !== "undefined" && this.data("progress-total") !== null) {
formData["progress_total"] = this.data("progress-total");
}

Expand Down
4 changes: 3 additions & 1 deletion src/CustomLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ public function FieldHolder($properties = [])
/** @var string $att */
$att = Convert::raw2htmlatt($this->confirmation);
$attrs[] = sprintf('data-message="%s"', $att);
if ($this->progressive) {

// With no ajax or progressive, use entwine to show confirm message
if ($this->progressive || $this->getNoAjax()) {
$classes[] = "confirm";
} else {
$attrs[] = 'onclick="return confirm(this.dataset.message);"';
Expand Down

0 comments on commit 358b069

Please sign in to comment.