(function ($) {
    $.field_rates = function (element, options) {
        var defaults = {
            field_name: 0
        }
        var plugin = this;
        plugin.settings = {}
        var $element = $(element),
            element = element;
        plugin.init = function () {
            plugin.settings = $.extend({}, defaults, options);
            let field_name = plugin.settings.field_name;
            $element.find('.wrapper-rate').click(function (e) {
                let $self = $(this);
                $element.find('.wrapper-rate .selected').hide();
                let rate_id = $self.data('rate_id');
                $self.find('.selected').show();

                $element.find(`input[name="${field_name}"]`).val(rate_id);
            });
        };
        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_rates = function (options) {
        return this.each(function () {
            if (undefined == $(this).data('field_rates')) {
                var plugin = new $.field_rates(this, options);
                $(this).data('field_rates', plugin);
            }
        });
    }
})(jQuery);
