From 7076343338ae3439f3c86f01144818abe8c31978 Mon Sep 17 00:00:00 2001 From: George Halkiadakis Date: Sun, 12 Mar 2023 07:16:23 +0200 Subject: add container helpers; constuct public directory-tree --- html/content/js/Plugins/quantity.js | 55 +++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 html/content/js/Plugins/quantity.js (limited to 'html/content/js/Plugins/quantity.js') diff --git a/html/content/js/Plugins/quantity.js b/html/content/js/Plugins/quantity.js new file mode 100644 index 0000000..f124c63 --- /dev/null +++ b/html/content/js/Plugins/quantity.js @@ -0,0 +1,55 @@ +$$plugins.define('quantity', ['dom'], function (element, options, dom) { + //const plugin = this, + // increaseButton = element.querySelector('.quantity__btn--inc'), + // decreaseButton = element.querySelector('.quantity__btn--dec'), + // input = element.querySelector('input'), + // maxQuantity = options.MaxQuantity, + // minQuantity = options.MinQuantity || 1; + + //let currentValue = parseInt(input.value); + + //checkButtons(); + //plugin.on('click', increaseButton, updateValue); + //plugin.on('click', decreaseButton, updateValue); + + //function updateValue(e) { + // const button = dom.closest(e.target, '[data-ref="quantity-control"]'), + // previousValue = currentValue; + // if (!button || button.classList.contains('disabled')) { + // return false; + // } + // if (button === increaseButton) { + // currentValue += 1; + // } else { + // currentValue -= 1; + // } + + // console.log(button) + // input.value = currentValue; + // checkButtons(); + // if (options.ItemId) { + // plugin.emit('cart:quantity.changed', { + // quantity: currentValue, + // item: options.ItemId, + // element: e.target, + // fail: function onFail() { + // currentValue = previousValue; + // } + // }); + // } + //} + + //function checkButtons() { + // if (currentValue > minQuantity) { + // decreaseButton.classList.remove('disabled'); + // } else { + // decreaseButton.classList.add('disabled'); + // } + + // if (currentValue < maxQuantity) { + // increaseButton.classList.remove('disabled'); + // } else { + // increaseButton.classList.add('disabled'); + // } + //} +}); -- cgit v1.2.3