Compare commits

...
12 Commits
8 changed files with 25 additions and 4 deletions
+1
View File
@@ -18,6 +18,7 @@ at :ref:`plugin-docs`.
item_variations
item_bundles
item_add-ons
item_meta_properties
questions
question_options
quotas
+1 -1
View File
@@ -19,4 +19,4 @@
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
# <https://www.gnu.org/licenses/>.
#
__version__ = "4.20.0"
__version__ = "4.21.0.dev0"
+1
View File
@@ -80,6 +80,7 @@ ALL_LANGUAGES = [
('de-informal', _('German (informal)')),
('ar', _('Arabic')),
('zh-hans', _('Chinese (simplified)')),
('zh-hant', _('Chinese (traditional)')),
('cs', _('Czech')),
('da', _('Danish')),
('nl', _('Dutch')),
@@ -335,7 +335,7 @@
id="cp_{{ form.pos.pk }}_item_{{ item.id }}"
aria-label="{% blocktrans with item=item.name %}Quantity of {{ item }} to order{% endblocktrans %}"
{% if item.description %} aria-describedby="cp-{{ form.pos.pk }}-item-{{ item.id }}-description"{% endif %}>
<button type="button" data-step="1" data-controls="cp_{{ form.pos.pk }}_item_{{ item.id }}" class="btn btn-default input-item-count-dec" aria-label="{% trans "Increase quantity" %}">+</button>
<button type="button" data-step="1" data-controls="cp_{{ form.pos.pk }}_item_{{ item.id }}" class="btn btn-default input-item-count-inc" aria-label="{% trans "Increase quantity" %}">+</button>
</div>
{% endif %}
</div>
@@ -21,7 +21,7 @@
</div>
<div role="rowgroup" class="firstchild-in-panel">
{% for line in cart.positions %}
<div role="row" class="row cart-row {% if hide_prices %}hide-prices{% endif %} {% if download %}has-downloads{% endif %}{% if editable %}editable{% endif %}">
<div role="row" class="row cart-row {% if hide_prices %}hide-prices{% endif %} {% if download %}has-downloads{% endif %}{% if editable %}editable{% endif %}" data-item="{{ line.item.id }}" data-count="{{ line.count }}">
<div role="cell" class="product">
<p>
{% if line.addon_to %}
@@ -344,6 +344,7 @@
<button type="button" data-step="-1" data-controls="item_{{ item.id }}" class="btn btn-default input-item-count-dec" aria-label="{% trans "Decrease quantity" %}"
{% if not ev.presale_is_running %}disabled{% endif %}>-</button>
<input type="number" class="form-control input-item-count" placeholder="0" min="0"
{% if item.min_per_order and item.min_per_order > 1 %}data-min="{{ item.min_per_order }}"{% endif %}
{% if not ev.presale_is_running %}disabled{% endif %}
{% if itemnum == 1 %}value="1"{% endif %}
{% if item.free_price %}
@@ -257,6 +257,7 @@
<div class="input-item-count-group">
<button type="button" data-step="-1" data-controls="variation_{{ item.id }}_{{ var.id }}" class="btn btn-default input-item-count-dec" aria-label="{% trans "Decrease quantity" %}">-</button>
<input type="number" class="form-control input-item-count" placeholder="0" min="0"
{% if item.min_per_order and item.min_per_order > 1 %}data-min="{{ item.min_per_order }}"{% endif %}
max="{{ var.order_max }}"
id="variation_{{ item.id }}_{{ var.id }}"
name="variation_{{ item.id }}_{{ var.id }}"
@@ -400,6 +401,7 @@
<button type="button" data-step="-1" data-controls="item_{{ item.id }}" class="btn btn-default input-item-count-dec" aria-label="{% trans "Decrease quantity" %}">-</button>
<input type="number" class="form-control input-item-count"
placeholder="0" min="0"
{% if item.min_per_order and item.min_per_order > 1 %}data-min="{{ item.min_per_order }}"{% endif %}
max="{{ item.order_max }}"
id="item_{{ item.id }}"
name="item_{{ item.id }}"
+17 -1
View File
@@ -121,10 +121,26 @@ var form_handlers = function (el) {
e.preventDefault();
var step = parseFloat(this.getAttribute("data-step"));
var controls = document.getElementById(this.getAttribute("data-controls"));
var currentValue = parseFloat(controls.value);
var currentValue = parseFloat(controls.value) || 0;
controls.value = Math.max(controls.min, Math.min(controls.max || Number.MAX_SAFE_INTEGER, (currentValue || 0) + step));
controls.dispatchEvent(new Event("change"));
});
el.find("input[data-min]").each(function(i) {
this.previousValue = parseFloat(this.value) || 0;
}).on("change", function(e) {
var currentValue = parseFloat(this.value) || 0;
var itemOrderMin = parseFloat(this.getAttribute("data-min")) || 0;
if (itemOrderMin) {
document.querySelectorAll(".cart-row[data-item='"+this.id.substring(5)+"']").forEach(function(row) {
itemOrderMin -= (parseFloat(row.getAttribute("data-count")) || 1)
});
if (itemOrderMin < 0) itemOrderMin = 0;
}
if (currentValue && currentValue < itemOrderMin) {
this.value = this.previousValue > currentValue ? 0 : itemOrderMin;
}
this.previousValue = this.value;
});
el.find("script[data-replace-with-qr]").each(function () {
var $div = $("<div>");