PageSourceSearch

https://image.irislink.com/rework_eshop/js/hs.quantity-counter.js

js irislink.com collected 2026-10-02 05:30:01 UTC 1,860 bytes, 92 lines download raw bytes

1/**
2 * Quantity Counter wrapper.
3 *
4 * @author Htmlstream
5 * @version 1.0
6 *
7 */
8;(function ($) {
9  'use strict';
10
11  $.HSCore.components.HSQantityCounter = {
12    /**
13     *
14     *
15     * @var Object _baseConfig
16     */
17    _baseConfig: {},
18
19    /**
20     *
21     *
22     * @var jQuery pageCollection
23     */
24    pageCollection: $(),
25
26    /**
27     * Initialization of Count quantity wrapper.
28     *
29     * @param String selector (optional)
30     * @param Object config (optional)
31     *
32     * @return jQuery pageCollection - collection of initialized items.
33     */
34
35    init: function (selector, config) {
36
37      this.collection = selector && $(selector).length ? $(selector) : $();
38      if (!$(selector).length) return;
39
40      this.config = config && $.isPlainObject(config) ?
41          $.extend({}, this._baseConfig, config) : this._baseConfig;
42
43      this.config.itemSelector = selector;
44
45      this.initCountQty();
46
47      return this.pageCollection;
48
49    },
50
51    initCountQty: function () {
52      //Variables
53      var $self = this,
54          collection = $self.pageCollection;
55
56      //Actions
57      this.collection.each(function (i, el) {
58        //Variables
59        var $this = $(el),
60            $plus = $this.find('.js-plus'),
61            $minus = $this.find('.js-minus'),
62            $result = $this.find('.js-result'),
63            resultVal = parseInt($result.val());
64
65        $plus.on('click', function (e) {
66          e.preventDefault();
67
68          resultVal += 1;
69
70          $result.val(resultVal);
71        });
72
73        $minus.on('click', function (e) {
74          e.preventDefault();
75
76          if (resultVal >= 1) {
77            resultVal -= 1;
78
79            $result.val(resultVal);
80          } else {
81            return false;
82          }
83        });
84
85        //Actions
86        collection = collection.add($this);
87      });
88    }
89
90  };
91
92})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.