mirror of
https://github.com/pretix/pretix.git
synced 2026-05-18 17:24:03 +00:00
refine onchange handling
This commit is contained in:
@@ -121,17 +121,19 @@ var form_handlers = function (el) {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var step = parseFloat(this.getAttribute("data-step"));
|
var step = parseFloat(this.getAttribute("data-step"));
|
||||||
var controls = document.getElementById(this.getAttribute("data-controls"));
|
var controls = document.getElementById(this.getAttribute("data-controls"));
|
||||||
var currentValue = parseFloat(controls.value);
|
var currentValue = parseFloat(controls.value) || 0;
|
||||||
var itemOrderMin = parseFloat(controls.getAttribute("data-min"))
|
controls.value = Math.max(controls.min, Math.min(controls.max || Number.MAX_SAFE_INTEGER, (currentValue || 0) + step));
|
||||||
controls.value = currentValue <= itemOrderMin && step < 0 ? 0 : Math.max(itemOrderMin || controls.min, Math.min(controls.max || Number.MAX_SAFE_INTEGER, (currentValue || 0) + step));
|
|
||||||
controls.dispatchEvent(new Event("change"));
|
controls.dispatchEvent(new Event("change"));
|
||||||
});
|
});
|
||||||
el.find("input[data-min]").on("blur", function(e) {
|
el.find("input[data-min]").each(function(i) {
|
||||||
var quantity = parseFloat(this.value);
|
this.previousValue = parseFloat(this.value) || 0;
|
||||||
var itemOrderMin = parseFloat(this.getAttribute("data-min"));
|
}).on("change", function(e) {
|
||||||
|
var quantity = parseFloat(this.value) || 0;
|
||||||
|
var itemOrderMin = parseFloat(this.getAttribute("data-min")) || 0;
|
||||||
if (quantity && quantity < itemOrderMin) {
|
if (quantity && quantity < itemOrderMin) {
|
||||||
this.value = itemOrderMin;
|
this.value = this.previousValue > quantity ? 0 : itemOrderMin;
|
||||||
}
|
}
|
||||||
|
this.previousValue = quantity;
|
||||||
});
|
});
|
||||||
|
|
||||||
el.find("script[data-replace-with-qr]").each(function () {
|
el.find("script[data-replace-with-qr]").each(function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user