Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shop2.queue.amount = function() {
- var $document = $(document);
- function validate(input) {
- var kind = input.data('kind'),
- max = input.data('max'),
- val = Number(input.val()),
- amount = 0,
- available;
- if (kind && max > 0) {
- $('input[data-kind=' + kind + ']').each(function() {
- amount += Number(this.value);
- });
- if (amount > max) {
- available = max - amount + val;
- input.val(available);
- shop2.msg(_s3Lang.JS_AVAILABLE_ONLY + ' ' + available, input);
- }
- }
- }
- $document.on('click', '.amount-minus', function() {
- var $this = $(this),
- text = $this.parents('.shop2-product-amount').find('input:text'),
- value = text.getVal();
- if (value) {
- value = value[0];
- }
- value -= shop2.options.amountDefaultInc;
- value = value.toFixed(5) - 0;
- if (value <= shop2.options.amountDefaultValue) {
- value = shop2.options.amountDefaultValue;
- }
- text.val(value);
- text.trigger('keyup');
- });
- $document.on('click', '.amount-plus', function() {
- var $this = $(this),
- text = $this.parents('.shop2-product-amount').find('input:text'),
- value = text.getVal();
- if (value) {
- value = value[0];
- }
- value += shop2.options.amountDefaultInc;
- value = value.toFixed(5) - 0;
- text.val(value);
- text.trigger('keyup');
- });
- $document.on('keyup', '.shop2-product-amount input:text', function() {
- var $this = $(this);
- validate($this);
- });
- $document.keyFilter('.shop2-product-amount input:text', {
- type: shop2.options.amountType
- });
- },
Add Comment
Please, Sign In to add comment