"use strict";
(function ($) {
    $.field_selectrates = function (element, options) {
        var defaults = {
            input_name: "",
        };
        var plugin = this;
        plugin.settings = {}
        let $element = $(element);
        plugin.init = function () {
            plugin.settings = $.extend({}, defaults, options);
            let input_name = plugin.settings.input_name;
            $element.find('.wrapper-rate').on('click',function (e) {
                let $self = $(this);
                let rate_id = $self.data('rate_id');
                $element.find('.wrapper-rate').removeClass('active');
                $self.addClass('active');
                $element.find(`input[name="${input_name}"]`).val(rate_id);
            });

        };
        plugin.example_function = function () {
        };
        plugin.init();
    }
    
    $.fn.field_selectrates = function (options) {
        
        return this.each(function () {
            
            if (undefined == $(this).data('field_selectrates')) {
                var plugin = new $.field_selectrates(this, options);
                $(this).data('field_selectrates', plugin);
            }
        });
    }
})(jQuery);
