(function ($) {
    $.field_incrementnumber = function (element, options) {
        var defaults = {
            field_name: ""
        }
        var plugin = this;
        plugin.settings = {}
        var $element = $(element),
            element = element;

        plugin.init = function () {
            plugin.settings = $.extend({}, defaults, options);
            $element.find('.handle-counter').handleCounter({
                minimum: 1,
                onChange: function (value) {
                    if (typeof plugin.onChange === "function") {
                        plugin.onChange(value);
                    }
                },
                onMinimum: function () {
                },
                onMaximize: function () {
                }
            })
        };
        plugin.getValue = function () {
            let field_name = plugin.settings.field_name;
            return $element.find(`input[name="${field_name}"]`).val();
        };
        plugin.example_function = function () {
        };
        plugin.init();
    }
    $.fn.field_incrementnumber = function (options) {
        return this.each(function () {

            if (undefined == $(this).data('field_incrementnumber')) {
                var plugin = new $.field_incrementnumber(this, options);
                $(this).data('field_incrementnumber', plugin);
            }
        });
    }
})(jQuery);
